adp-fluent-plugin-graphite 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adp-fluent-plugin-graphite.gemspec +1 -1
- data/lib/fluent/plugin/out_graphite.rb +6 -26
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3c6bf04e2986897933cc69157dd99b04ab407487de4c21d4199a3497dc6afe4
|
4
|
+
data.tar.gz: 269daf2a466386e8b12b022e69661d97d092d8260ccd301911482df80fd0ae7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c900a4339ba745ac7971a683d520f505c8ed4957775df8c2bbfd5b54226b3dd0c84483450f19306be0e169e90db60f22d3f23425a2255418083085ee3c947c2
|
7
|
+
data.tar.gz: b785046cabb45dedee8ba4c791c0324e0484b6d1c289b207635e203a7775d140294e683edf59c0596549cc4c616e59f975df7ace61181100422fb9297599de66
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = 'adp-fluent-plugin-graphite'
|
6
|
-
gem.version = '0.0.
|
6
|
+
gem.version = '0.0.12'
|
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'
|
@@ -33,44 +33,24 @@ module Fluent::Plugin
|
|
33
33
|
es.each do |time, record|
|
34
34
|
emit_tag = tag.dup
|
35
35
|
log.info("Emit graphite plugin: #{record}")
|
36
|
+
metrics = format_metrics(emit_tag, record)
|
36
37
|
|
37
38
|
# implemented to immediate call post method in this loop, because graphite-api.gem has the buffers.
|
38
|
-
post(
|
39
|
+
post(metrics, time)
|
39
40
|
end
|
40
41
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def format_metrics(tag, record)
|
44
|
-
filtered_record = if @name_keys
|
45
|
-
record.select { |k, v| @name_keys.include?(k.to_s) }
|
46
|
-
else
|
47
|
-
# defined @name_key_pattern
|
48
|
-
record.select { |k, v| @name_key_pattern.match(k.to_s) }
|
49
|
-
end
|
50
|
-
|
51
|
-
return nil if filtered_r
|
52
|
-
|
53
|
-
ecord.empty?
|
54
|
-
|
55
45
|
metrics = {}
|
56
|
-
tag =
|
57
|
-
filtered_record.each do |k, v|
|
58
|
-
key = case @tag_for
|
59
|
-
when 'ignore' then k.to_s
|
60
|
-
when 'prefix' then "#{tag}.#{k}"
|
61
|
-
when 'suffix' then "#{k}.#{tag}"
|
62
|
-
end
|
63
|
-
|
64
|
-
key = key.gsub(/(\s|\/)+/, '_') # cope with in the case of containing symbols or spaces in the key of the record like in_dstat.
|
65
|
-
metrics[key] = v.to_f
|
66
|
-
end
|
46
|
+
metrics[tag] = 1
|
67
47
|
metrics
|
68
48
|
end
|
69
49
|
|
70
|
-
def post(
|
50
|
+
def post(metric, time)
|
71
51
|
trial ||= 1
|
72
|
-
@client.metrics(
|
73
|
-
log.warn("Sending metrics: #{
|
52
|
+
@client.metrics(metric, time)
|
53
|
+
log.warn("Sending metrics: #{metric}")
|
74
54
|
rescue Errno::ETIMEDOUT
|
75
55
|
# after long periods with nothing emitted, the connection will be closed and result in timeout
|
76
56
|
if trial <= @max_retries
|