fluent-plugin-prometheus 1.8.5 → 2.0.0

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: 5679e5c8d8872be0448075a8c1e05c395b1f9c06a0267f568a788c77dc12dc62
4
- data.tar.gz: 786191b3092cf3745ab97425e4aebb4b1cb524c907433d0f4e091dbb6d14b7f9
3
+ metadata.gz: e3250eed2a2f1156410b9e67005f7e23fdb822111dd780690ce61ee4967db7cf
4
+ data.tar.gz: dd1d3aa0defd1ac16f7d4e6e75dd7b6b7c9caff11f9e16288dc9b787d8f3ef9e
5
5
  SHA512:
6
- metadata.gz: 1b7c49f483ad596641edf01226e4282db10b72dd0117867884d0df4cf6ca0cf23c48e54eab6a2a22ca3ecae845ad8edda6e75d3532853a200b7a57ac8caca423
7
- data.tar.gz: 344b9a363c49067056c4366f46b6b9f3bddf955e22a0155215158b13420027479c0a5e41da1a86b2baaf71e0b01256d90d0a0c8269c322ebe3616c861ce35a98
6
+ metadata.gz: ed531d2e8e383f54f3ff68c695cb63c0a2922a17ced661a109e50c50546a571aeb45747cba079274b451f41bdd506737d43c035140e28db7e5a427a83a1126b9
7
+ data.tar.gz: 7fab4fb99f73a770f0a87d88341078f089e78fd865ba28aba4634d04dfa5b5baa7ab8e7b1942fdc5ef96f6306ef379d7da2335bc7856ea150cb69c8749635f94
@@ -0,0 +1,26 @@
1
+ name: linux
2
+ on:
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ build:
7
+ runs-on: ${{ matrix.os }}
8
+ strategy:
9
+ fail-fast: false
10
+ matrix:
11
+ ruby: [ '2.4', '2.5', '2.6', '2.7' ]
12
+ os:
13
+ - ubuntu-latest
14
+ name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby }}
20
+ - name: unit testing
21
+ env:
22
+ CI: true
23
+ run: |
24
+ gem install bundler rake
25
+ bundle install --jobs 4 --retry 3
26
+ bundle exec rake spec
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 2.0.0 - 2021/02/18
2
+
3
+ * Update prometheus-client dependency to 2.1.0 or later
4
+
1
5
  Release 1.8.5 - 2020/11/24
2
6
 
3
7
  * in_prometheus_monitor: Support USR2 reload
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-prometheus"
3
- spec.version = "1.8.5"
3
+ spec.version = "2.0.0"
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.}
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.require_paths = ["lib"]
15
15
 
16
16
  spec.add_dependency "fluentd", ">= 1.9.1", "< 2"
17
- spec.add_dependency "prometheus-client", "< 0.10"
17
+ spec.add_dependency "prometheus-client", ">= 2.1.0"
18
18
  spec.add_development_dependency "bundler"
19
19
  spec.add_development_dependency "rake"
20
20
  spec.add_development_dependency "rspec"
@@ -76,14 +76,14 @@ module Fluent::Plugin
76
76
 
77
77
  @monitor_info.each do |name, metric|
78
78
  if info[name]
79
- metric.set(label, info[name])
79
+ metric.set(info[name], labels: label)
80
80
  end
81
81
  end
82
82
 
83
83
  timekeys = info["buffer_timekeys"]
84
84
  if timekeys && !timekeys.empty?
85
- @buffer_newest_timekey.set(label, timekeys.max)
86
- @buffer_oldest_timekey.set(label, timekeys.min)
85
+ @buffer_newest_timekey.set(timekeys.max, labels: label)
86
+ @buffer_oldest_timekey.set(timekeys.min, labels: label)
87
87
  end
88
88
  end
89
89
  end
@@ -100,7 +100,7 @@ module Fluent::Plugin
100
100
  if @registry.exist?(name)
101
101
  @registry.get(name)
102
102
  else
103
- @registry.gauge(name, docstring)
103
+ @registry.gauge(name, docstring: docstring, labels: @base_labels.keys + [:plugin_id, :plugin_category, :type])
104
104
  end
105
105
  end
106
106
  end
@@ -161,9 +161,9 @@ module Fluent::Plugin
161
161
  monitor_info.each do |name, metric|
162
162
  if info[name]
163
163
  if metric.is_a?(::Prometheus::Client::Gauge)
164
- metric.set(label, info[name])
164
+ metric.set(info[name], labels: label)
165
165
  elsif metric.is_a?(::Prometheus::Client::Counter)
166
- metric.increment(label, info[name] - metric.get(label))
166
+ metric.increment(by: info[name] - metric.get(labels: label), labels: label)
167
167
  end
168
168
  end
169
169
  end
@@ -172,9 +172,9 @@ module Fluent::Plugin
172
172
  instance_vars_info.each do |name, metric|
173
173
  if info['instance_variables'][name]
174
174
  if metric.is_a?(::Prometheus::Client::Gauge)
175
- metric.set(label, info['instance_variables'][name])
175
+ metric.set(info['instance_variables'][name], labels: label)
176
176
  elsif metric.is_a?(::Prometheus::Client::Counter)
177
- metric.increment(label, info['instance_variables'][name] - metric.get(label))
177
+ metric.increment(by: info['instance_variables'][name] - metric.get(labels: label), labels: label)
178
178
  end
179
179
  end
180
180
  end
@@ -193,7 +193,7 @@ module Fluent::Plugin
193
193
  if next_time && start_time
194
194
  wait = next_time - start_time
195
195
  end
196
- @metrics[:retry_wait].set(label, wait.to_f)
196
+ @metrics[:retry_wait].set(wait.to_f, labels: label)
197
197
  end
198
198
  end
199
199
  end
@@ -209,7 +209,7 @@ module Fluent::Plugin
209
209
  if @registry.exist?(name)
210
210
  @registry.get(name)
211
211
  else
212
- @registry.gauge(name, docstring)
212
+ @registry.gauge(name, docstring: docstring, labels: @base_labels.keys + [:plugin_id, :type])
213
213
  end
214
214
  end
215
215
 
@@ -217,7 +217,7 @@ module Fluent::Plugin
217
217
  if @registry.exist?(name)
218
218
  @registry.get(name)
219
219
  else
220
- @registry.public_send(@gauge_or_counter, name, docstring)
220
+ @registry.public_send(@gauge_or_counter, name, docstring: docstring, labels: @base_labels.keys + [:plugin_id, :type])
221
221
  end
222
222
  end
223
223
  end
@@ -73,8 +73,8 @@ module Fluent::Plugin
73
73
  # Very fragile implementation
74
74
  pe = watcher.instance_variable_get(:@pe)
75
75
  label = labels(info, watcher.path)
76
- @metrics[:inode].set(label, pe.read_inode)
77
- @metrics[:position].set(label, pe.read_pos)
76
+ @metrics[:inode].set(pe.read_inode, labels: label)
77
+ @metrics[:position].set(pe.read_pos, labels: label)
78
78
  end
79
79
  end
80
80
  end
@@ -91,7 +91,7 @@ module Fluent::Plugin
91
91
  if @registry.exist?(name)
92
92
  @registry.get(name)
93
93
  else
94
- @registry.gauge(name, docstring)
94
+ @registry.gauge(name, docstring: docstring, labels: @base_labels.keys + [:plugin_id, :type, :path])
95
95
  end
96
96
  end
97
97
  end
@@ -188,7 +188,7 @@ module Fluent
188
188
  end
189
189
 
190
190
  begin
191
- @gauge = registry.gauge(element['name'].to_sym, element['desc'])
191
+ @gauge = registry.gauge(element['name'].to_sym, docstring: element['desc'], labels: @base_labels.keys)
192
192
  rescue ::Prometheus::Client::Registry::AlreadyRegisteredError
193
193
  @gauge = Fluent::Plugin::Prometheus::Metric.get(registry, element['name'].to_sym, :gauge, element['desc'])
194
194
  end
@@ -201,7 +201,7 @@ module Fluent
201
201
  value = @key.call(record)
202
202
  end
203
203
  if value
204
- @gauge.set(labels(record, expander), value)
204
+ @gauge.set(value, labels: labels(record, expander))
205
205
  end
206
206
  end
207
207
  end
@@ -210,7 +210,7 @@ module Fluent
210
210
  def initialize(element, registry, labels)
211
211
  super
212
212
  begin
213
- @counter = registry.counter(element['name'].to_sym, element['desc'])
213
+ @counter = registry.counter(element['name'].to_sym, docstring: element['desc'], labels: @base_labels.keys)
214
214
  rescue ::Prometheus::Client::Registry::AlreadyRegisteredError
215
215
  @counter = Fluent::Plugin::Prometheus::Metric.get(registry, element['name'].to_sym, :counter, element['desc'])
216
216
  end
@@ -229,7 +229,7 @@ module Fluent
229
229
  # ignore if record value is nil
230
230
  return if value.nil?
231
231
 
232
- @counter.increment(labels(record, expander), value)
232
+ @counter.increment(by: value, labels: labels(record, expander))
233
233
  end
234
234
  end
235
235
 
@@ -241,7 +241,7 @@ module Fluent
241
241
  end
242
242
 
243
243
  begin
244
- @summary = registry.summary(element['name'].to_sym, element['desc'])
244
+ @summary = registry.summary(element['name'].to_sym, docstring: element['desc'], labels: @base_labels.keys)
245
245
  rescue ::Prometheus::Client::Registry::AlreadyRegisteredError
246
246
  @summary = Fluent::Plugin::Prometheus::Metric.get(registry, element['name'].to_sym, :summary, element['desc'])
247
247
  end
@@ -254,7 +254,7 @@ module Fluent
254
254
  value = @key.call(record)
255
255
  end
256
256
  if value
257
- @summary.observe(labels(record, expander), value)
257
+ @summary.observe(value, labels: labels(record, expander))
258
258
  end
259
259
  end
260
260
  end
@@ -271,9 +271,9 @@ module Fluent
271
271
  buckets = element['buckets'].split(/,/).map(&:strip).map do |e|
272
272
  e[/\A\d+.\d+\Z/] ? e.to_f : e.to_i
273
273
  end
274
- @histogram = registry.histogram(element['name'].to_sym, element['desc'], {}, buckets)
274
+ @histogram = registry.histogram(element['name'].to_sym, docstring: element['desc'], labels: @base_labels.keys, buckets: buckets)
275
275
  else
276
- @histogram = registry.histogram(element['name'].to_sym, element['desc'])
276
+ @histogram = registry.histogram(element['name'].to_sym, docstring: element['desc'], labels: @base_labels.keys)
277
277
  end
278
278
  rescue ::Prometheus::Client::Registry::AlreadyRegisteredError
279
279
  @histogram = Fluent::Plugin::Prometheus::Metric.get(registry, element['name'].to_sym, :histogram, element['desc'])
@@ -287,7 +287,7 @@ module Fluent
287
287
  value = @key.call(record)
288
288
  end
289
289
  if value
290
- @histogram.observe(labels(record, expander), value)
290
+ @histogram.observe(value, labels: labels(record, expander))
291
291
  end
292
292
  end
293
293
  end
@@ -178,20 +178,19 @@ shared_examples_for 'instruments record' do
178
178
 
179
179
  it 'instruments counter metric' do
180
180
  expect(counter.type).to eq(:counter)
181
- expect(counter.get({test_key: 'test_value', key: 'foo1'})).to be_kind_of(Numeric)
182
- expect(counter_with_accessor.get({test_key: 'test_value', key: 'foo6'})).to be_kind_of(Numeric)
181
+ expect(counter.get(labels: {test_key: 'test_value', key: 'foo1'})).to be_kind_of(Numeric)
182
+ expect(counter_with_accessor.get(labels: {test_key: 'test_value', key: 'foo6'})).to be_kind_of(Numeric)
183
183
  end
184
184
 
185
185
  it 'instruments gauge metric' do
186
186
  expect(gauge.type).to eq(:gauge)
187
- expect(gauge.get({test_key: 'test_value', key: 'foo2'})).to eq(100)
187
+ expect(gauge.get(labels: {test_key: 'test_value', key: 'foo2'})).to eq(100)
188
188
  end
189
189
 
190
190
  it 'instruments summary metric' do
191
191
  expect(summary.type).to eq(:summary)
192
- expect(summary.get({test_key: 'test_value', key: 'foo3'})).to be_kind_of(Hash)
193
- expect(summary.get({test_key: 'test_value', key: 'foo3'})[0.99]).to eq(100)
194
- expect(summary_with_accessor.get({test_key: 'test_value', key: 'foo5'})[0.99]).to eq(100)
192
+ expect(summary.get(labels: {test_key: 'test_value', key: 'foo3'})).to be_kind_of(Hash)
193
+ expect(summary_with_accessor.get(labels: {test_key: 'test_value', key: 'foo5'})["sum"]).to eq(100)
195
194
  end
196
195
 
197
196
  it 'instruments histogram metric' do
@@ -200,8 +199,8 @@ shared_examples_for 'instruments record' do
200
199
  end
201
200
 
202
201
  expect(histogram.type).to eq(:histogram)
203
- expect(histogram.get({test_key: 'test_value', key: 'foo4'})).to be_kind_of(Hash)
204
- expect(histogram.get({test_key: 'test_value', key: 'foo4'})[10]).to eq(5) # 4 + `es` in before
202
+ expect(histogram.get(labels: {test_key: 'test_value', key: 'foo4'})).to be_kind_of(Hash)
203
+ expect(histogram.get(labels: {test_key: 'test_value', key: 'foo4'})["10"]).to eq(5) # 4 + `es` in before
205
204
  end
206
205
  end
207
206
 
@@ -231,7 +230,7 @@ shared_examples_for 'instruments record' do
231
230
  expect(counter).to be_kind_of(::Prometheus::Client::Metric)
232
231
  key, _ = counter.values.find {|k,v| v == 100 }
233
232
  expect(key).to be_kind_of(Hash)
234
- expect(key[:foo]).to eq(100)
233
+ expect(key[:foo]).to eq("100")
235
234
  end
236
235
  end
237
236
 
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: 1.8.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-24 00:00:00.000000000 Z
11
+ date: 2021-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: prometheus-client
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "<"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0.10'
39
+ version: 2.1.0
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "<"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: '0.10'
46
+ version: 2.1.0
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -107,6 +107,7 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - ".github/workflows/linux.yml"
110
111
  - ".gitignore"
111
112
  - ".rspec"
112
113
  - ".travis.yml"
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubygems_version: 3.0.3
162
+ rubygems_version: 3.1.4
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: A fluent plugin that collects metrics and exposes for Prometheus.