logstash-output-itda 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: daec719b2d44e8ebdb4a364bbde8f1ac387dbcae33b65672720fbb9fb8e9f16a
4
+ data.tar.gz: 8ae77fb0eddc39e19673250cf00eed96013f5a7882ea09c5301dfc1bba9665b5
5
+ SHA512:
6
+ metadata.gz: ab6f0b8b64f697713542c589c2c801128bf3b046887cfcd307494c0a9b34a784c45722cdfbf522116531f75b51fbc6c488dc5d5fd7d593cf6a61b7473bd3dc6d
7
+ data.tar.gz: d06b45b560425602f0bc9c36c978c7fc7bb7a8eb109954462a128d99b6681189b4005dd1beedde066f08fa4b8506a93c6d6d144293365a113a7833c9271f47fd
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,10 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash itda output plugin along its way.
3
+
4
+ Contributors:
5
+ * Sameer Pokarna (sameerpokarna)
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash Itda Output Plugin, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
@@ -0,0 +1,2 @@
1
+ # logstash-output-itda
2
+ ITDA output plugin. This plugin will help to re-direct logstash data into BMC TrueSight IT Data Analytics!
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
@@ -0,0 +1,133 @@
1
+ # logstash-output-itda
2
+ A logstash output plugin to send data into ITDA.
3
+
4
+ ## Documentation
5
+
6
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
7
+
8
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
9
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
10
+
11
+ ## Need Help?
12
+
13
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
14
+
15
+ ## Developing
16
+
17
+ ### 1. Plugin Developement and Testing
18
+
19
+ #### Code
20
+ - To get started, you'll need JRuby with the Bundler gem installed.
21
+
22
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
23
+
24
+ - Install dependencies
25
+ ```sh
26
+ bundle install
27
+ ```
28
+
29
+ #### Test
30
+
31
+ - Update your dependencies
32
+
33
+ ```sh
34
+ bundle install
35
+ ```
36
+
37
+ - Run tests
38
+
39
+ ```sh
40
+ bundle exec rspec
41
+ ```
42
+
43
+ ### 2. Running your unpublished Plugin in Logstash
44
+
45
+ #### 2.1 Run in a local Logstash clone
46
+
47
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
48
+ ```ruby
49
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
50
+ ```
51
+ - Install plugin
52
+ ```sh
53
+ # Logstash 2.3 and higher
54
+ bin/logstash-plugin install --no-verify
55
+
56
+ # Prior to Logstash 2.3
57
+ bin/plugin install --no-verify
58
+
59
+ ```
60
+ - Run Logstash with your plugin
61
+ ```sh
62
+ bin/logstash -e 'filter {awesome {}}'
63
+ ```
64
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
65
+
66
+ #### 2.2 Run in an installed Logstash
67
+
68
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
69
+
70
+ - Build your plugin gem
71
+ ```sh
72
+ gem build logstash-filter-awesome.gemspec
73
+ ```
74
+ - Install the plugin from the Logstash home
75
+ ```sh
76
+ # Logstash 2.3 and higher
77
+ bin/logstash-plugin install --no-verify
78
+
79
+ # Prior to Logstash 2.3
80
+ bin/plugin install --no-verify
81
+
82
+ ```
83
+ - Start Logstash and proceed to test the plugin
84
+
85
+
86
+ ## Pre-requisites
87
+
88
+ To be able to use this plugin, you need the following
89
+ * Installation of BMC TrueSight IT Data Analytics
90
+ * Create a Data collector of type (Receive over HTTP/HTTPS)
91
+
92
+ ## Usage
93
+ Once you have installed the plugin, you can use it in the logstash configuration, by specifying the "itda" output.
94
+ E.g.
95
+ ```sh
96
+ itda {
97
+ host => "localhost"
98
+ port => "4646"
99
+ protocol => "http"
100
+ }
101
+ ```
102
+
103
+ ```sh
104
+ itda {
105
+ host => "localhost"
106
+ port => "4545"
107
+ protocol => "http"
108
+ messageonly => "true"
109
+ }
110
+ ```
111
+
112
+ ### Fields
113
+
114
+ | Property | Value (Default) | Description |
115
+ --------------|-----------------|-------------|
116
+ | host | | Host of the ITDA HTTP/HTTPS collector |
117
+ | port | | Port of the ITDA HTTP/HTTPS collector |
118
+ | protocol | | Protocol of the ITDA HTTP/HTTPS collector |
119
+ | messageonly | false | Only send the message, and not the other fields |
120
+
121
+
122
+
123
+ ## Contributing
124
+
125
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
126
+
127
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
128
+
129
+ It is more important to the community that you are able to contribute.
130
+
131
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
132
+
133
+
@@ -0,0 +1,76 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "logstash/json"
5
+
6
+ # Using hashes:
7
+ # # [source,ruby]
8
+ # # This plugin can be used to send all logstash data into BMC TrueSight IT Data Analytics.
9
+ # # To sue this plugin, an HTTP/HTTPS collector should be created in the ITDA instance, and
10
+ # # this configuration should point to the same.
11
+ # # The various properties supported are -
12
+ # # ----------------------------------
13
+ # # match => {
14
+ # # "host" => "<hostname>/<ipaddress>"
15
+ # # "port" => "nnnn"
16
+ # # "api_key" => "<key>"
17
+ # # "protocol" => "http/https"
18
+ # # "messageonly" => "true/false"
19
+ # # }
20
+ # # ----------------------------------
21
+ class LogStash::Outputs::Itda < LogStash::Outputs::Base
22
+ config_name "itda"
23
+
24
+ config :host, :validate => :string, :required => true
25
+ config :port, :validate => :string, :required => true
26
+ config :api_key, :validate => :string, :required => false
27
+ config :protocol, :validate => :string, :required => false
28
+ config :messageonly, :validate => :string, :required => false
29
+
30
+ public
31
+ def register
32
+ require "net/http"
33
+ require "uri"
34
+ @url = "#{@protocol}://#{@host}:#{@port}/"
35
+ @uri = URI.parse(@url)
36
+ @client = Net::HTTP.new(@uri.host, @uri.port)
37
+
38
+ end # def register
39
+
40
+ public
41
+ def receive(event)
42
+
43
+ event.remove('@timestamp')
44
+ event.remove('@version')
45
+
46
+ request = Net::HTTP::Post.new(@uri.path)
47
+ request.basic_auth(@api_key, '')
48
+
49
+ @logger.debug("ITDA event", :itda_event => event)
50
+
51
+ begin
52
+ if @messageonly
53
+ message = event.remove('message')
54
+ @logger.debug("ITDA message", :itda_message => message)
55
+
56
+ request.body = message
57
+ request.add_field("Content-Type", 'text/plain')
58
+ else
59
+ request.body = LogStash::Json.dump(event)
60
+ request.add_field("Content-Type", 'application/json')
61
+ end
62
+ response = @client.request(request)
63
+ @logger.warn("ITDA convo", :request => request.inspect, :response => response.inspect)
64
+ raise unless response.code == '200'
65
+ rescue Exception => e
66
+ @logger.warn(
67
+ "Unhandled exception",
68
+ :request => request.inspect,
69
+ :response => response.inspect,
70
+ :exception => e.inspect
71
+ )
72
+ end
73
+
74
+ return "Event received"
75
+ end # def event
76
+ end # class LogStash::Outputs::Itda
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-itda'
3
+ s.version = "0.1.0"
4
+ s.licenses = ["Apache License (2.0)"]
5
+ s.summary = "This example output does nothing."
6
+ s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["sameerpokarna"]
8
+ s.email = "sameerpokarna@gmail.com"
9
+ s.homepage = "https://github.com/sameerpokarna/logstash-output-itda"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.3.0"
22
+ s.add_runtime_dependency "logstash-codec-plain"
23
+ s.add_development_dependency "logstash-devutils"
24
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/outputs/itda"
4
+ require "logstash/codecs/plain"
5
+ require "logstash/event"
6
+
7
+ describe LogStash::Outputs::Itda do
8
+ let(:sample_event) { LogStash::Event.new }
9
+ let(:output) { LogStash::Outputs::Example.new }
10
+
11
+ before do
12
+ output.register
13
+ end
14
+
15
+ describe "receive message" do
16
+ subject { output.receive(sample_event) }
17
+
18
+ it "returns a string" do
19
+ expect(subject).to eq("Event received")
20
+ end
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-itda
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sameerpokarna
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 2.3.0
19
+ name: logstash-core
20
+ prerelease: false
21
+ type: :runtime
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ name: logstash-codec-plain
34
+ prerelease: false
35
+ type: :runtime
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ name: logstash-devutils
48
+ prerelease: false
49
+ type: :development
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem is a Logstash plugin required to be installed on top of the
56
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
57
+ gem is not a stand-alone program
58
+ email: sameerpokarna@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - CHANGELOG.md
64
+ - CONTRIBUTORS
65
+ - DEVELOPER.md
66
+ - Gemfile
67
+ - README.md
68
+ - lib/logstash/outputs/itda.rb
69
+ - logstash-output-itda.gemspec
70
+ - spec/outputs/itda_spec.rb
71
+ homepage: https://github.com/sameerpokarna/logstash-output-itda
72
+ licenses:
73
+ - Apache License (2.0)
74
+ metadata:
75
+ logstash_plugin: 'true'
76
+ logstash_group: output
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.6.11
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: This example output does nothing.
97
+ test_files:
98
+ - spec/outputs/itda_spec.rb