fluent-plugin-jopentsdb 0.0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0336206ff4d44fb2c96248c6bd45b577bba5e239
4
+ data.tar.gz: e401cae16988170d3937157e03fcc763593b89b8
5
+ SHA512:
6
+ metadata.gz: d28abf1de5a94a3fac68fb1dc78cd136bbc48691e3229bdd795cae7b8b961af253f1e12eb7704e32493373de6e3eb4f0fc525aeb450677a8361380c5334f09e5
7
+ data.tar.gz: 429dc76b692b8f217c5efdcaa6ffa82e3f9a8db468e8d82f46fda0a2e346f38cdc97578ebda4048edb827d8a49b5e597763e6fe0b26bd3656b5dbe02fdffcf1d
@@ -0,0 +1,65 @@
1
+ module Fluent
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'json'
5
+ class jOpenTsdbOutput < Output
6
+ Fluent::Plugin.register_output("jopentsdb", self)
7
+
8
+ config_param :host, :string, :default => 'localhost'
9
+ config_param :port, :integer, :default => 4242
10
+
11
+ def configure(conf)
12
+ super
13
+ end
14
+
15
+ def start
16
+ super
17
+ connect
18
+ end
19
+
20
+ def connect
21
+ @socket = TCPSocket.new(@host, @port)
22
+ $log.info "connected to opentsdb at #{@host}:#{@port}"
23
+ end
24
+
25
+ def shutdown
26
+ super
27
+ @socket.shutdown(Socket::SHUT_RDWR)
28
+ end
29
+
30
+ def emit(tag, es, chain)
31
+ es.each do |time,record|
32
+ $log.debug "opentsdb output processing record #{record}"
33
+ put_metric(record)
34
+ end
35
+
36
+ chain.next
37
+ end
38
+
39
+ def put_metric(record)
40
+ $log.debug "#{record}"
41
+ message = record
42
+ $log.debug message
43
+ begin
44
+ uri = URI.parse("http://#{@host}:#{@port}/api/put")
45
+ request = Net::HTTP::Post.new(uri)
46
+ request.content_type = "application/json"
47
+ request["Accept"] = "Application/json"
48
+ request.body = JSON.dump(message)
49
+ req_options = {
50
+ use_ssl: uri.scheme == "https",
51
+ }
52
+
53
+ response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
54
+ http.request(request)
55
+ end
56
+
57
+ rescue Errno::EPIPE, Errno::ECONNRESET => e
58
+ $log.warn("Connection to opentsdb server died",
59
+ :exception => e, :host => @host, :port => @port)
60
+ sleep(2)
61
+ connect
62
+ end
63
+ end
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-jopentsdb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dmytro Vedetskyi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
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
+ - !ruby/object:Gem::Dependency
28
+ name: fluentd
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Fluentd plugin to save json metrics in OpenTSDB
42
+ email:
43
+ - dmytro.vedetskyi@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/fluent/plugin/out_jopentsdb.rb
49
+ homepage: https://github.com/helli0n/fluent-plugin-jopentsdb
50
+ licenses: []
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ requirements: []
67
+ rubyforge_project:
68
+ rubygems_version: 2.4.8
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: Fluentd plugin to save json metrics in OpenTSDB
72
+ test_files: []