fluent-plugin-prometheus 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 0015d77e131a78ad42b181d8d57a981b07398298
4
- data.tar.gz: 69cb9279858bef00990af84ee4f82533bb5b4b78
3
+ metadata.gz: 2e788403193d1cee84b22745fc1df7daff846687
4
+ data.tar.gz: 2daaa89406fd5fdfd40af646e0710f0f852b4a9e
5
5
  SHA512:
6
- metadata.gz: 8b51025e9ec268a8dc2252c58a99b80a67d019a15933ea763b05f1c5260a2e1ed5c8f282103ed4f0bfc48ab531e73decb1d74c71a294a3b1f147aa5f147165e2
7
- data.tar.gz: ce3da1320eb05ee4d5e5fc258ee4b671a6647a84d7e4960fbed6769240ea6c99ece2be130af334436f32b0d5e40e6061e69730ae61366721022b75fbd7a2e148
6
+ metadata.gz: b74333d759e146f0ca7c0ab6a6457cefa771f6018fbdd5f20dcae0ac13d74b0ce4b028791ee9045124abe9a9d243a900f341538797b774e56426223e9f66c4d5
7
+ data.tar.gz: 438a688500a58fd8084b4401987ff192c551405cda063838221041cdfe632db6ea6641aac0ca9a48e5420a9adcfc42837cd117e039f1e05f07558b176114bbce
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-prometheus"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.1.2"
4
4
  spec.authors = ["Masahiro Sano"]
5
5
  spec.email = ["sabottenda@gmail.com"]
6
6
  spec.summary = %q{A fluent plugin that collects metrics and exposes for Prometheus.}
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
15
15
 
16
16
  spec.add_dependency "fluentd"
17
17
  spec.add_dependency "prometheus-client"
18
- spec.add_development_dependency "bundler", ">= 0.12.13"
18
+ spec.add_development_dependency "bundler"
19
19
  spec.add_development_dependency "rake"
20
20
  spec.add_development_dependency "rspec"
21
21
  spec.add_development_dependency "test-unit"
@@ -17,10 +17,10 @@ module Fluent
17
17
  super
18
18
  hostname = Socket.gethostname
19
19
  expander = Fluent::Prometheus.placeholder_expnader(log)
20
- expander.prepare_placeholders(Time.now.to_i, {}, {'hostname' => hostname})
20
+ placeholders = expander.prepare_placeholders({'hostname' => hostname})
21
21
  @base_labels = Fluent::Prometheus.parse_labels_elements(conf)
22
22
  @base_labels.each do |key, value|
23
- @base_labels[key] = expander.expand(value)
23
+ @base_labels[key] = expander.expand(value, placeholders)
24
24
  end
25
25
 
26
26
  @monitor_agent = MonitorAgentInput.new
@@ -67,16 +67,17 @@ module Fluent
67
67
  end
68
68
 
69
69
  def instrument(tag, es, metrics)
70
- placeholder_options = {
70
+ placeholder_values = {
71
71
  'tag' => tag,
72
72
  'hostname' => @hostname,
73
73
  }
74
74
 
75
75
  es.each do |time, record|
76
- @placeholder_expander.prepare_placeholders(time, record, placeholder_options)
76
+ placeholders = record.merge(placeholder_values)
77
+ placeholders = @placeholder_expander.prepare_placeholders(placeholders)
77
78
  metrics.each do |metric|
78
79
  begin
79
- metric.instrument(record, @placeholder_expander)
80
+ metric.instrument(record, @placeholder_expander, placeholders)
80
81
  rescue => e
81
82
  log.warn "prometheus: failed to instrument a metric.", error_class: e.class, error: e, tag: tag, name: metric.name
82
83
  router.emit_error_event(tag, time, record, e)
@@ -106,10 +107,10 @@ module Fluent
106
107
  @base_labels = labels.merge(@base_labels)
107
108
  end
108
109
 
109
- def labels(record, expander)
110
+ def labels(record, expander, placeholders)
110
111
  label = {}
111
112
  @base_labels.each do |k, v|
112
- label[k] = expander.expand(v)
113
+ label[k] = expander.expand(v, placeholders)
113
114
  end
114
115
  label
115
116
  end
@@ -143,9 +144,9 @@ module Fluent
143
144
  end
144
145
  end
145
146
 
146
- def instrument(record, expander)
147
+ def instrument(record, expander, placeholders)
147
148
  if record[@key]
148
- @gauge.set(labels(record, expander), record[@key])
149
+ @gauge.set(labels(record, expander, placeholders), record[@key])
149
150
  end
150
151
  end
151
152
  end
@@ -160,14 +161,14 @@ module Fluent
160
161
  end
161
162
  end
162
163
 
163
- def instrument(record, expander)
164
+ def instrument(record, expander, placeholders)
164
165
  # use record value of the key if key is specified, otherwise just increment
165
166
  value = @key ? record[@key] : 1
166
167
 
167
168
  # ignore if record value is nil
168
169
  return if value.nil?
169
170
 
170
- @counter.increment(labels(record, expander), value)
171
+ @counter.increment(labels(record, expander, placeholders), value)
171
172
  end
172
173
  end
173
174
 
@@ -185,9 +186,9 @@ module Fluent
185
186
  end
186
187
  end
187
188
 
188
- def instrument(record, expander)
189
+ def instrument(record, expander, placeholders)
189
190
  if record[@key]
190
- @summary.add(labels(record, expander), record[@key])
191
+ @summary.add(labels(record, expander, placeholders), record[@key])
191
192
  end
192
193
  end
193
194
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-16 00:00:00.000000000 Z
11
+ date: 2016-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.12.13
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.12.13
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement