adp-fluent-plugin-graphite 0.0.10 → 0.0.14
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 +4 -4
- data/adp-fluent-plugin-graphite.gemspec +1 -1
- data/lib/fluent/plugin/out_graphite.rb +6 -25
- 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: 21120861eb51aec332d4284c136334ea9fce73141f40323d1113e0d22f2958f0
|
4
|
+
data.tar.gz: a5f0d97c4e056764d8bfd87dd02e4a5b733c9df89558ee3ec1155f307ce89400
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95d3c4eb3c8527b372cdb151a4da8b067b3a23eda527584789687deb7c0e8135b59c472c28f43585b49e608a4a4f951573ce5dc4174c2ca7f70dea72f485d9dc
|
7
|
+
data.tar.gz: dd18d9731cd866f0214f8c0073559b6cfbe95c718801a659a7d228c05a7919174b9e0b14f386c3b2d82bbd75700b84d373e9f94d90cbc016cc369179dd788353
|
@@ -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.14'
|
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'
|
@@ -7,7 +7,7 @@ module Fluent::Plugin
|
|
7
7
|
config_param :host, :string
|
8
8
|
config_param :port, :integer, default: 2003
|
9
9
|
config_param :tag_for, :string, default: 'prefix'
|
10
|
-
config_param :
|
10
|
+
config_param :monitoring_key, :string
|
11
11
|
config_param :name_key_pattern, :string, default: nil
|
12
12
|
config_param :max_retries, :integer, default: 3
|
13
13
|
|
@@ -33,7 +33,7 @@ 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
|
-
|
36
|
+
metrics = format_metrics(emit_tag, record)
|
37
37
|
|
38
38
|
# implemented to immediate call post method in this loop, because graphite-api.gem has the buffers.
|
39
39
|
post(metrics, time)
|
@@ -42,34 +42,15 @@ module Fluent::Plugin
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def format_metrics(tag, record)
|
45
|
-
filtered_record = if @name_keys
|
46
|
-
record.select { |k, v| @name_keys.include?(k.to_s) }
|
47
|
-
else
|
48
|
-
# defined @name_key_pattern
|
49
|
-
record.select { |k, v| @name_key_pattern.match(k.to_s) }
|
50
|
-
end
|
51
|
-
|
52
|
-
return nil if filtered_record.empty?
|
53
|
-
|
54
45
|
metrics = {}
|
55
|
-
|
56
|
-
filtered_record.each do |k, v|
|
57
|
-
key = case @tag_for
|
58
|
-
when 'ignore' then k.to_s
|
59
|
-
when 'prefix' then "#{tag}.#{k}"
|
60
|
-
when 'suffix' then "#{k}.#{tag}"
|
61
|
-
end
|
62
|
-
|
63
|
-
key = key.gsub(/(\s|\/)+/, '_') # cope with in the case of containing symbols or spaces in the key of the record like in_dstat.
|
64
|
-
metrics[key] = v.to_f
|
65
|
-
end
|
46
|
+
metrics[@monitoring_key + "." + tag] = 1
|
66
47
|
metrics
|
67
48
|
end
|
68
49
|
|
69
|
-
def post(
|
50
|
+
def post(metric, time)
|
70
51
|
trial ||= 1
|
71
|
-
@client.metrics(
|
72
|
-
log.warn("Sending metrics: #{
|
52
|
+
@client.metrics(metric, time)
|
53
|
+
log.warn("Sending metrics: #{metric}")
|
73
54
|
rescue Errno::ETIMEDOUT
|
74
55
|
# after long periods with nothing emitted, the connection will be closed and result in timeout
|
75
56
|
if trial <= @max_retries
|