logstash-output-opentsdb_using_filter_metrics 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZTU2MmQ2YTdhMzUzMWE1YWJlZWNlN2EyOWFhNjUzM2MyYWJmMzk4Nw==
5
+ data.tar.gz: !binary |-
6
+ OThlMDgyYTFhMWZiMzljYmFhNGE1YTc3ODY3ZTBmOTBmMGVjZmM3NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MTE4ZmQ2OTBiNDU3YzJkZDhjNTU0Yjk1MDJjMjZjN2U3N2Q5NWJiOGI5NzFl
10
+ YzM1M2Y5ZjZlYmIxODAwMDY1N2U2OGYxZTcwODM5YmIyNGMxM2MwZTJhZWM3
11
+ MjUzMGUwZTYzYmVhNzhkZjMxMzBiMTUzNWFmYzkyNzg4ODIxNTk=
12
+ data.tar.gz: !binary |-
13
+ MTlhMmQ2Y2YzMjJkYmNiZGY3MmRlZGRhYTdiMjFkYzc1NmVkMDAxNGE1NjJh
14
+ NmUxNjMxZmIyY2I5MjJiYTIzN2VmZTJiM2M4MDRmZmFlYzE1Njg0ODFkOTIx
15
+ MzVmODdmNjFlNTQ5YmI0MTUxZmFjZThjNzhiNDQ3MTQ2NDJhZDU=
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ ## 2.0.1
2
+ - Add encoding: utf-8 to spec files. This can help prevent issues during testing.
3
+ ## 2.0.0
4
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
5
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
6
+ - Dependency on logstash-core update to 2.0
7
+
data/CONTRIBUTORS ADDED
@@ -0,0 +1,11 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Aaron Mildenstein (untergeek)
6
+ * Pier-Hugues Pellerin (ph)
7
+
8
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
9
+ Logstash, and you aren't on the list above and want to be, please let us know
10
+ and we'll make sure you're here. Contributions from folks like you are what make
11
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ # platforms :jruby do
5
+ # gem 'logstash-devutils', '~> 0.0.18'
6
+ # gem 'logstash-core', '~> 2.2'
7
+ # end
8
+
9
+ gem 'logstash-core', '~> 2.2.0', :platforms => :jruby
10
+ gem 'logstash-devutils', '~> 0.0.18', :platforms => :jruby
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/NOTICE.TXT ADDED
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
data/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # logstash-output-opentsdb_using_filter_metrics 플러그인 적용하기
2
+
3
+ - 의존성 파일 설치
4
+ ```sh
5
+ bundle install
6
+ ```
7
+ - 빌드하기
8
+ ```
9
+ gem build logstash-output-opentsdb_using_filter_metrics.gemspec
10
+ ```
11
+ - 플러그인 설치
12
+ ```
13
+ /kakao/program/logstash/bin/plugin install logstash-output-opentsdb_using_filter_metrics-2.0.0.gem
14
+ ```
15
+
16
+ # Logstash Plugin
17
+
18
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
19
+
20
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
21
+
22
+ ## Documentation
23
+
24
+ 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/).
25
+
26
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
27
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
28
+
29
+ ## Need Help?
30
+
31
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
32
+
33
+ ## Developing
34
+
35
+ ### 1. Plugin Developement and Testing
36
+
37
+ #### Code
38
+ - To get started, you'll need JRuby with the Bundler gem installed.
39
+
40
+ - 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).
41
+
42
+ - Install dependencies
43
+ ```sh
44
+ bundle install
45
+ ```
46
+
47
+ #### Test
48
+
49
+ - Update your dependencies
50
+
51
+ ```sh
52
+ bundle install
53
+ ```
54
+
55
+ - Run tests
56
+
57
+ ```sh
58
+ bundle exec rspec
59
+ ```
60
+
61
+ ### 2. Running your unpublished Plugin in Logstash
62
+
63
+ #### 2.1 Run in a local Logstash clone
64
+
65
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
66
+ ```ruby
67
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
68
+ ```
69
+ - Install plugin
70
+ ```sh
71
+ bin/plugin install --no-verify
72
+ ```
73
+ - Run Logstash with your plugin
74
+ ```sh
75
+ bin/logstash -e 'filter {awesome {}}'
76
+ ```
77
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
78
+
79
+ #### 2.2 Run in an installed Logstash
80
+
81
+ 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:
82
+
83
+ - Build your plugin gem
84
+ ```sh
85
+ gem build logstash-filter-awesome.gemspec
86
+ ```
87
+ - Install the plugin from the Logstash home
88
+ ```sh
89
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
90
+ ```
91
+ - Start Logstash and proceed to test the plugin
92
+
@@ -0,0 +1,113 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "socket"
5
+
6
+ # This output allows you to pull metrics from your logs and ship them to
7
+ # opentsdb. Opentsdb is an open source tool for storing and graphing metrics.
8
+ #
9
+ class LogStash::Outputs::OpentsdbUsingFilterMetrics < LogStash::Outputs::Base
10
+ config_name "opentsdb_using_filter_metrics"
11
+
12
+ # Enable debugging.
13
+ config :debug, :validate => :boolean, :default => false, :deprecated => "This setting was never used by this plugin. It will be removed soon."
14
+
15
+ # The address of the opentsdb server.
16
+ config :host, :validate => :string, :default => "localhost"
17
+
18
+ # The port to connect on your graphite server.
19
+ config :port, :validate => :number, :default => 4242
20
+
21
+ # Metric name
22
+ config :metric_name, :validate => :string, :required => true
23
+
24
+ # tag seperator
25
+ config :tag_separator, :validate => :string, :required => true
26
+
27
+ config :hostname, :validate => :string, :default => Socket.gethostname
28
+
29
+
30
+ def register
31
+ connect
32
+ end # def register
33
+
34
+ def connect
35
+ # TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory.
36
+ begin
37
+ @socket = TCPSocket.new(@host, @port)
38
+ @logger.info("Connected to opentsdb server")
39
+ rescue Errno::ECONNREFUSED => e
40
+ @logger.warn("Connection refused to opentsdb server, sleeping...",
41
+ :host => @host, :port => @port)
42
+ sleep(2)
43
+ retry
44
+ end
45
+ end # def connect
46
+
47
+ public
48
+ def receive(event)
49
+
50
+
51
+ # Opentsdb message format: put metric timestamp value tagname=tagvalue tag2=value2\n
52
+
53
+ # Catch exceptions like ECONNRESET and friends, reconnect on failure.
54
+
55
+ event_hash = event.to_hash
56
+ tags = Array.new
57
+
58
+ event_hash.each do |h_key, h_value|
59
+ tags = h_key.split(@tag_separator)
60
+ if tags.length > 1
61
+ metric_name = @metric_name
62
+ metric_value = h_value["count"]
63
+ tags << "host" << hostname
64
+
65
+ begin
66
+ name = metric_name
67
+ value = metric_value
68
+
69
+ # The first part of the message
70
+ message = ['put',
71
+ event.sprintf(name),
72
+ event.sprintf("%{+%s}"),
73
+ event.sprintf(value),
74
+ ].join(" ")
75
+
76
+ # If we have have tags we need to add it to the message
77
+ event_tags = []
78
+ unless tags.nil?
79
+ Hash[*tags.flatten].each do |tag_name,tag_value|
80
+ # Interprete variables if neccesary
81
+ real_tag_name = event.sprintf(tag_name)
82
+ real_tag_value = event.sprintf(tag_value)
83
+ event_tags << [real_tag_name , real_tag_value ].join('=')
84
+ end
85
+ message+=' '+event_tags.join(' ')
86
+ end
87
+
88
+ # TODO(sissel): Test error cases. Catch exceptions. Find fortune and glory.
89
+ tries = 3
90
+ begin
91
+ @socket.puts(message)
92
+ rescue Errno::EPIPE, Errno::ECONNRESET => e
93
+ sleep(1)
94
+ tries -= 1
95
+ if tries > 0
96
+ connect
97
+ retry
98
+ else
99
+ @logger.warn("Connection to opentsdb server died",
100
+ :exception => e, :host => @host, :port => @port, :query => message)
101
+ end
102
+ end
103
+
104
+ # TODO(sissel): resend on failure
105
+ # TODO(sissel): Make 'resend on failure' tunable; sometimes it's OK to
106
+ # drop metrics.
107
+ end # @metrics.each
108
+ end # tags.length > 1
109
+ end # event_hash.each
110
+
111
+
112
+ end # def receive
113
+ end # class LogStash::Outputs::OpentsdbUsingFilterMetrics
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-opentsdb_using_filter_metrics'
3
+ s.version = "2.0.0"
4
+ s.licenses = ["Apache License (2.0)"]
5
+ s.summary = "This output allows you to pull metrics['count'] from metrics filter and ship them to opentsdb"
6
+ s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
7
+ s.authors = ["eunkyung-kim"]
8
+ s.email = "paulina0206@gmail.com"
9
+ s.require_paths = ["lib"]
10
+
11
+ # Files
12
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
13
+ # Tests
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+
16
+ # Special flag to let us know this is actually a logstash plugin
17
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
18
+
19
+ # Gem dependencies
20
+ s.add_runtime_dependency "logstash-core", ">= 2.2.0", "< 3.0.0" if RUBY_PLATFORM == 'java'
21
+ s.add_development_dependency "logstash-devutils"
22
+ end
@@ -0,0 +1,2 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-opentsdb_using_filter_metrics
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - eunkyung-kim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-devutils
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: This gem is a logstash plugin required to be installed on top of the
28
+ Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not
29
+ a stand-alone program
30
+ email: paulina0206@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - CHANGELOG.md
36
+ - CONTRIBUTORS
37
+ - Gemfile
38
+ - LICENSE
39
+ - NOTICE.TXT
40
+ - README.md
41
+ - lib/logstash/outputs/opentsdb_using_filter_metrics.rb
42
+ - logstash-output-opentsdb_using_filter_metrics.gemspec
43
+ - spec/outputs/opentsdb_using_filter_metrics_spec.rb
44
+ homepage:
45
+ licenses:
46
+ - Apache License (2.0)
47
+ metadata:
48
+ logstash_plugin: 'true'
49
+ logstash_group: output
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.4.5
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: This output allows you to pull metrics['count'] from metrics filter and ship
70
+ them to opentsdb
71
+ test_files:
72
+ - spec/outputs/opentsdb_using_filter_metrics_spec.rb