adp-fluent-plugin-graphite 0.0.11 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ccc0434567a05d9a3845e7addddd73b4ba7c4fc7b5a5d048975c704b33a09c6
4
- data.tar.gz: 2fbb1d973ff684abbcb9e6698dc9c14815425b481b7ada47bba9d75eae8d8c68
3
+ metadata.gz: 3d7ea3516d03ae9df0d626c97453daa20ca97c86491e4ebbeb47bdf8bb0a95e3
4
+ data.tar.gz: f306f5437dd3fbff7394985cf3ad4618bcecde930d24d74be8529918ad5a2b62
5
5
  SHA512:
6
- metadata.gz: 6f41e09278d517a79fc9d004eafaea6cab4b4ac72d8e5cef27ead3cdf51de27b2dca8bb9e65c9c7d43b9748b0bb71037177b96b28c72df1cf94e69187d19f361
7
- data.tar.gz: 79e3fe164b2bcb206b4d2e5e8a777557f372db0fd86afd4a46e29868eb47205e7ba2da69f79d0dd0efe083dda003f08de937d1e14d965c59d0377a0e0527112f
6
+ metadata.gz: 5ebe013292fc99265b692e060b5a3041f2b2ef770becb3f53f20eb372ecb7a4f594e51bfa8ee607fcb7c059918f52bca0d334f876a119dbd9d51031aa2eebc63
7
+ data.tar.gz: f902ca5c94366c979a009bbbfe39cbc3951c06ee18ff27b7ec2c2d177423c07d593e98cc16184e43cef81770cc37398ee96c574226f06cc9019d8061812747ae
@@ -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.11'
6
+ gem.version = '0.0.15'
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 :name_keys, :string, default: nil
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,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(emit_tag, time)
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 = tag.sub(/\.$/, '') # may include a dot at the end of the emit_tag fluent-mixin-rewrite-tag-name returns. remove it.
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[@monitoring_key + "." + tag] = 1
67
47
  metrics
68
48
  end
69
49
 
70
- def post(metrics, time)
50
+ def post(metric, time)
71
51
  trial ||= 1
72
- @client.metrics(metrics, time)
73
- log.warn("Sending metrics: #{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
@@ -90,7 +70,25 @@ module Fluent::Plugin
90
70
  end
91
71
 
92
72
  def connect_client!
93
- @client = GraphiteAPI.new(graphite: "#{@host}:#{@port}")
73
+ options = {
74
+ # Required: valid URI {udp,tcp}://host:port/?timeout=seconds
75
+ graphite: "udp://#{@host}:#{@port}",
76
+
77
+ # Optional: results are aggregated in 60 seconds slices ( default is 60 )
78
+ slice: 60,
79
+
80
+ # Optional: send to graphite every 60 seconds ( default is 0 - direct send )
81
+ interval: 30,
82
+
83
+ # Optional: set the max age in seconds for records reanimation ( default is 12 hours )
84
+ cache: 4 * 60 * 60,
85
+
86
+ # Optional: The default aggregation method for multiple reports in the same slice (default is :sum).
87
+ # Possible options: :sum, :avg, :replace
88
+ default_aggregation_method: :avg
89
+ }
90
+ @client = GraphiteAPI.new options
91
+ GraphiteAPI::Logger.init level: :debug
94
92
  log.info("starting client")
95
93
  end
96
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adp-fluent-plugin-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi SUZUKI