fluent-plugin-opentsdb 0.1.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.
- data/.gitignore +18 -0
- data/README.md +52 -0
- data/Rakefile +11 -0
- data/fluent-plugin-opentsdb.gemspec +19 -0
- data/lib/fluent/plugin/out_opentsdb.rb +76 -0
- metadata +98 -0
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# fluent-plugin-opentsdb
|
2
|
+
|
3
|
+
## Component
|
4
|
+
|
5
|
+
### OpenTsdbOutput
|
6
|
+
|
7
|
+
Plugin to graph fluent-plugin-numeric-monitor values in OpenTSDB
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
### OpenTsdbOutput
|
12
|
+
|
13
|
+
Given a fluent-plugin-numeric-monitor configuration like the following:
|
14
|
+
|
15
|
+
<match apache.log.**>
|
16
|
+
type numeric_monitor
|
17
|
+
unit minute
|
18
|
+
tag monitor.duration
|
19
|
+
aggregate tag
|
20
|
+
input_tag_remove_prefix apache.log
|
21
|
+
monitor_key duration
|
22
|
+
percentiles 90,95
|
23
|
+
</match>
|
24
|
+
|
25
|
+
To graph in OpenTSDB:
|
26
|
+
|
27
|
+
<match monitor.duration>
|
28
|
+
type opentsdb
|
29
|
+
host localhost
|
30
|
+
port 4242
|
31
|
+
metric_prefix http
|
32
|
+
metric_num hits
|
33
|
+
metric_durations latency
|
34
|
+
monitor_key_tag action
|
35
|
+
tags env, localhost
|
36
|
+
</match>
|
37
|
+
|
38
|
+
Will send OpenTSDB put commands like the following:
|
39
|
+
|
40
|
+
put http.latency.pct90 1358206603 79668.0 action=samplepage, env=localhost
|
41
|
+
put http.latency.pct90 1358206603 85224.0 action=samplepage, env=localhost
|
42
|
+
put http.hits 1358206603 103 action=samplepage, env=localhost
|
43
|
+
|
44
|
+
## TODO
|
45
|
+
|
46
|
+
* add tests
|
47
|
+
* more documents
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
* License
|
52
|
+
* Apache License, Version 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.name = "fluent-plugin-opentsdb"
|
4
|
+
gem.version = "0.1.1"
|
5
|
+
gem.authors = ["Emmet Murphy"]
|
6
|
+
gem.email = ["emmet@onekingslane.com"]
|
7
|
+
gem.description = %q{Fluentd plugin to graph fluent-plugin-numeric-monitor values in OpenTSDB}
|
8
|
+
gem.summary = %q{Fluentd plugin to graph fluent-plugin-numeric-monitor values in OpenTSDB}
|
9
|
+
gem.homepage = "https://github.com/emurphy/fluent-plugin-opentsdb"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
|
16
|
+
gem.add_development_dependency "fluentd"
|
17
|
+
gem.add_development_dependency "rake"
|
18
|
+
gem.add_runtime_dependency "fluentd"
|
19
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fluent
|
2
|
+
class OpenTsdbOutput < Output
|
3
|
+
Fluent::Plugin.register_output("opentsdb", self)
|
4
|
+
|
5
|
+
config_param :host, :string, :default => 'localhost'
|
6
|
+
config_param :port, :integer, :default => 4242
|
7
|
+
config_param :metric_prefix, :string, :default => 'monitor'
|
8
|
+
config_param :metric_num, :string, :default => 'num'
|
9
|
+
config_param :metric_durations, :string, :default => 'duration'
|
10
|
+
config_param :tags, :string, :default => nil
|
11
|
+
config_param :monitor_key_tag, :string, :default => 'key'
|
12
|
+
|
13
|
+
def configure(conf)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def start
|
18
|
+
super
|
19
|
+
connect
|
20
|
+
end
|
21
|
+
|
22
|
+
def connect
|
23
|
+
@socket = TCPSocket.new(@host, @port)
|
24
|
+
$log.info "connected to opentsdb at #{@host}:#{@port}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def shutdown
|
28
|
+
super
|
29
|
+
@socket.shutdown(Socket::SHUT_RDWR)
|
30
|
+
end
|
31
|
+
|
32
|
+
def emit(tag, es, chain)
|
33
|
+
es.each do |time,record|
|
34
|
+
$log.debug "opentsdb output processing record #{record}"
|
35
|
+
record.each do |metric, value|
|
36
|
+
value = 0 if value.nil? or value.to_s.empty?
|
37
|
+
#$log.debug "metric[-4,4]=#{metric[-4,4]}, metric[-14..-3]=#{metric[-14..-3]}"
|
38
|
+
if metric[-4, 4] == '_num'
|
39
|
+
name = [@metric_prefix, @metric_num].join('.')
|
40
|
+
put_metric(name, value, time, metric[0..-5])
|
41
|
+
elsif metric[-14..-3] == '_percentile_'
|
42
|
+
name = [@metric_prefix, @metric_durations, 'pct' + metric[-2,2]].join('.')
|
43
|
+
put_metric(name, value, time, metric[0..-15])
|
44
|
+
else
|
45
|
+
name = [@metric_prefix, @metric_durations, metric[-3, 3]].join('.')
|
46
|
+
put_metric(name, value, time, metric[0..-5])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
chain.next
|
52
|
+
end
|
53
|
+
|
54
|
+
def put_metric(name, value, time, monitor_key_name)
|
55
|
+
tags = [@monitor_key_tag, monitor_key_name].join('=')
|
56
|
+
unless @tags.nil?
|
57
|
+
i = 0;
|
58
|
+
@tags.gsub(/ /, '').split(',').each do |val|
|
59
|
+
tags << (i == 0 ? ' ' : '')
|
60
|
+
tags << (i % 2 == 0 ? "#{val}=" : "#{val} ")
|
61
|
+
i += 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
message = ['put', name, time, value, tags].join(' ')
|
65
|
+
#$log.debug message
|
66
|
+
begin
|
67
|
+
@socket.puts(message)
|
68
|
+
rescue Errno::EPIPE, Errno::ECONNRESET => e
|
69
|
+
$log.warn("Connection to opentsdb server died",
|
70
|
+
:exception => e, :host => @host, :port => @port)
|
71
|
+
sleep(2)
|
72
|
+
connect
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-opentsdb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Emmet Murphy
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fluentd
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Fluentd plugin to graph fluent-plugin-numeric-monitor values in OpenTSDB
|
63
|
+
email:
|
64
|
+
- emmet@onekingslane.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- fluent-plugin-opentsdb.gemspec
|
73
|
+
- lib/fluent/plugin/out_opentsdb.rb
|
74
|
+
homepage: https://github.com/emurphy/fluent-plugin-opentsdb
|
75
|
+
licenses: []
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 1.8.25
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: Fluentd plugin to graph fluent-plugin-numeric-monitor values in OpenTSDB
|
98
|
+
test_files: []
|