fluent-plugin-graphite 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-graphite.gemspec +2 -1
- data/lib/fluent/plugin/out_graphite.rb +25 -6
- data/test/plugin/test_out_graphite.rb +19 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02cf8a6679ad334eb0e532d8777b74dee55f2182
|
4
|
+
data.tar.gz: 3d832195d3b3b51aac2aae953898e709146e2779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f29680eb0e6c9b510aacc5e98f4a86c12748a1afc0b87b2cb2534252bc350a5543a9bcb49dd86535bff0615d41d472b982ae6f29033036777fac1011db39fbb5
|
7
|
+
data.tar.gz: 5801fe77f4c62e6e16de13e575c42864403df0535cbc56b11c782fb31afa148a5799886731948d76e7dac073330d6cc6f3048ba2268bb3a4ec326a52b4bed392
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'fluent-plugin-graphite'
|
6
|
-
gem.version = '0.0.
|
6
|
+
gem.version = '0.0.7'
|
7
7
|
gem.authors = ['Satoshi SUZUKI']
|
8
8
|
gem.email = 'studio3104.com@gmail.com'
|
9
9
|
gem.homepage = 'https://github.com/studio3104/fluent-plugin-graphite'
|
@@ -21,4 +21,5 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_runtime_dependency 'fluent-mixin-rewrite-tag-name'
|
22
22
|
gem.add_runtime_dependency 'graphite-api'
|
23
23
|
gem.add_development_dependency 'rake'
|
24
|
+
gem.add_development_dependency 'test-unit', '~> 3.2.0'
|
24
25
|
end
|
@@ -24,7 +24,7 @@ class Fluent::GraphiteOutput < Fluent::Output
|
|
24
24
|
|
25
25
|
def start
|
26
26
|
super
|
27
|
-
|
27
|
+
connect_client!
|
28
28
|
end
|
29
29
|
|
30
30
|
def configure(conf)
|
@@ -47,6 +47,8 @@ class Fluent::GraphiteOutput < Fluent::Output
|
|
47
47
|
if @name_key_pattern
|
48
48
|
@name_key_pattern = Regexp.new(@name_key_pattern)
|
49
49
|
end
|
50
|
+
# How many times to retry the call if timeout raised
|
51
|
+
@max_retries ||= 3
|
50
52
|
end
|
51
53
|
|
52
54
|
def emit(tag, es, chain)
|
@@ -64,9 +66,9 @@ class Fluent::GraphiteOutput < Fluent::Output
|
|
64
66
|
|
65
67
|
def format_metrics(tag, record)
|
66
68
|
filtered_record = if @name_keys
|
67
|
-
record.select { |k,v| @name_keys.include?(k) }
|
69
|
+
record.select { |k,v| @name_keys.include?(k.to_s) }
|
68
70
|
else # defined @name_key_pattern
|
69
|
-
record.select { |k,v| @name_key_pattern.match(k) }
|
71
|
+
record.select { |k,v| @name_key_pattern.match(k.to_s) }
|
70
72
|
end
|
71
73
|
|
72
74
|
return nil if filtered_record.empty?
|
@@ -75,9 +77,9 @@ class Fluent::GraphiteOutput < Fluent::Output
|
|
75
77
|
tag = tag.sub(/\.$/, '') # may include a dot at the end of the emit_tag fluent-mixin-rewrite-tag-name returns. remove it.
|
76
78
|
filtered_record.each do |k, v|
|
77
79
|
key = case @tag_for
|
78
|
-
when 'ignore' then k
|
79
|
-
when 'prefix' then tag
|
80
|
-
when 'suffix' then k
|
80
|
+
when 'ignore' then k.to_s
|
81
|
+
when 'prefix' then "#{tag}.#{k}"
|
82
|
+
when 'suffix' then "#{k}.#{tag}"
|
81
83
|
end
|
82
84
|
|
83
85
|
key = key.gsub(/(\s|\/)+/, '_') # cope with in the case of containing symbols or spaces in the key of the record like in_dstat.
|
@@ -87,10 +89,27 @@ class Fluent::GraphiteOutput < Fluent::Output
|
|
87
89
|
end
|
88
90
|
|
89
91
|
def post(metrics, time)
|
92
|
+
trial ||= 1
|
90
93
|
@client.metrics(metrics, time)
|
94
|
+
rescue Errno::ETIMEDOUT
|
95
|
+
# after long periods with nothing emitted, the connection will be closed and result in timeout
|
96
|
+
if trial <= @max_retries
|
97
|
+
log.warn "out_graphite: connection timeout to #{@host}:#{@port}. Reconnecting... "
|
98
|
+
trial += 1
|
99
|
+
connect_client!
|
100
|
+
retry
|
101
|
+
else
|
102
|
+
log.error "out_graphite: ERROR: connection timeout to #{@host}:#{@port}. Exceeded max_retries #{@max_retries}"
|
103
|
+
end
|
91
104
|
rescue Errno::ECONNREFUSED
|
92
105
|
log.warn "out_graphite: connection refused by #{@host}:#{@port}"
|
93
106
|
rescue SocketError => se
|
94
107
|
log.warn "out_graphite: socket error by #{@host}:#{@port} :#{se}"
|
108
|
+
rescue StandardError => e
|
109
|
+
log.error "out_graphite: ERROR: #{e}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def connect_client!
|
113
|
+
@client = GraphiteAPI.new(graphite: "#{@host}:#{@port}")
|
95
114
|
end
|
96
115
|
end
|
@@ -83,7 +83,7 @@ class GraphiteOutputTest < Test::Unit::TestCase
|
|
83
83
|
assert_raise(Fluent::ConfigError) { d = create_driver(CONFIG_SPECIFY_BOTH_NAME_KEYS_AND_NAME_KEY_PATTERN) }
|
84
84
|
end
|
85
85
|
|
86
|
-
def
|
86
|
+
def test_format_metrics_strings
|
87
87
|
record = {
|
88
88
|
'hostname' => 'localhost.localdomain',
|
89
89
|
'dstat.total cpu usage.usr' => '0.0',
|
@@ -94,6 +94,24 @@ class GraphiteOutputTest < Test::Unit::TestCase
|
|
94
94
|
'dstat.total cpu usage.siq' => '0.0'
|
95
95
|
}
|
96
96
|
|
97
|
+
run_format_metrics_assertions(record)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_format_metrics_symbols
|
101
|
+
record = {
|
102
|
+
:'hostname' => 'localhost.localdomain',
|
103
|
+
:'dstat.total cpu usage.usr' => '0.0',
|
104
|
+
:'dstat.total cpu usage.sys' => '0.0',
|
105
|
+
:'dstat.total cpu usage.idl' => '100.0',
|
106
|
+
:'dstat.total cpu usage.wai' => '0.0',
|
107
|
+
:'dstat.total cpu usage.hiq' => '0.0',
|
108
|
+
:'dstat.total cpu usage.siq' => '0.0'
|
109
|
+
}
|
110
|
+
|
111
|
+
run_format_metrics_assertions(record)
|
112
|
+
end
|
113
|
+
|
114
|
+
def run_format_metrics_assertions(record)
|
97
115
|
d = create_driver
|
98
116
|
m1 = d.instance.format_metrics('test.', record)
|
99
117
|
assert_equal m1, { 'test.dstat.total_cpu_usage.usr' => 0.0, 'test.dstat.total_cpu_usage.sys' => 0.0, 'test.dstat.total_cpu_usage.idl' => 100.0, 'test.dstat.total_cpu_usage.wai' => 0.0, 'test.dstat.total_cpu_usage.hiq' => 0.0, 'test.dstat.total_cpu_usage.siq' => 0.0 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-graphite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Satoshi SUZUKI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test-unit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.2.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.2.0
|
69
83
|
description: fluentd output plugin to send metrics to graphite
|
70
84
|
email: studio3104.com@gmail.com
|
71
85
|
executables: []
|
@@ -102,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
116
|
version: '0'
|
103
117
|
requirements: []
|
104
118
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.5.1
|
106
120
|
signing_key:
|
107
121
|
specification_version: 4
|
108
122
|
summary: fluentd output plugin to send metrics to graphite
|