fluent-plugin-prometheus 2.0.0 → 2.0.3

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: e3250eed2a2f1156410b9e67005f7e23fdb822111dd780690ce61ee4967db7cf
4
- data.tar.gz: dd1d3aa0defd1ac16f7d4e6e75dd7b6b7c9caff11f9e16288dc9b787d8f3ef9e
3
+ metadata.gz: 21b4b3d81d41fadb057a133293f2629b39961faaadcb7caebbd885c10ed344d1
4
+ data.tar.gz: dbd8aa719306aa164f373c781f568b82bee27fc44bfc88e86c4ea5d31c5ce545
5
5
  SHA512:
6
- metadata.gz: ed531d2e8e383f54f3ff68c695cb63c0a2922a17ced661a109e50c50546a571aeb45747cba079274b451f41bdd506737d43c035140e28db7e5a427a83a1126b9
7
- data.tar.gz: 7fab4fb99f73a770f0a87d88341078f089e78fd865ba28aba4634d04dfa5b5baa7ab8e7b1942fdc5ef96f6306ef379d7da2335bc7856ea150cb69c8749635f94
6
+ metadata.gz: ca73efb455416a5e7c022793c17ae088cd685f5751e3497a501f9af880a5f9e970dd838c939d3b61e9145c92e2a0d3acff3d61fbde35a88c7f29e52b148de5c4
7
+ data.tar.gz: 9feaab5d5b45e6e9cb1bd48ea3bc47381db6c9cc806e4782fab18df21b093f4034ca8215202e32f64cd776ea695a385f195b3b02ab22679e8b3c01b97b2bd27c
@@ -1,16 +1,24 @@
1
1
  name: linux
2
2
  on:
3
- - push
4
- - pull_request
3
+ push:
4
+ branches: [master]
5
+ pull_request:
6
+ branches: [master]
5
7
  jobs:
6
8
  build:
7
9
  runs-on: ${{ matrix.os }}
10
+ continue-on-error: ${{ matrix.experimental }}
8
11
  strategy:
9
12
  fail-fast: false
10
13
  matrix:
11
- ruby: [ '2.4', '2.5', '2.6', '2.7' ]
14
+ ruby: [ '3.1', '3.0', '2.7', '2.6' ]
12
15
  os:
13
16
  - ubuntu-latest
17
+ experimental: [false]
18
+ include:
19
+ - ruby: head
20
+ os: ubuntu-latest
21
+ experimental: true
14
22
  name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }}
15
23
  steps:
16
24
  - uses: actions/checkout@v2
data/ChangeLog CHANGED
@@ -1,3 +1,15 @@
1
+ Release 2.0.3 - 2022/05/06
2
+
3
+ * in_prometheus_output_monitor: Fix a bug where output_status_num_errors metric is missing
4
+
5
+ Release 2.0.2 - 2021/08/02
6
+
7
+ * in_prometheus_output_monitor: Follow Fluentd's core metrics mechanism
8
+
9
+ Release 2.0.1 - 2021/04/08
10
+
11
+ * out_prometheus: Allow for lookup by symbol as well as string
12
+
1
13
  Release 2.0.0 - 2021/02/18
2
14
 
3
15
  * Update prometheus-client dependency to 2.1.0 or later
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-prometheus"
3
- spec.version = "2.0.0"
3
+ spec.version = "2.0.3"
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.}
@@ -133,18 +133,26 @@ module Fluent::Plugin
133
133
 
134
134
  monitor_info = {
135
135
  # buffer metrics
136
- 'buffer_total_queued_size' => @metrics[:buffer_total_queued_size],
137
- 'buffer_stage_length' => @metrics[:buffer_stage_length],
138
- 'buffer_stage_byte_size' => @metrics[:buffer_stage_byte_size],
139
- 'buffer_queue_length' => @metrics[:buffer_queue_length],
140
- 'buffer_queue_byte_size' => @metrics[:buffer_queue_byte_size],
141
- 'buffer_available_buffer_space_ratios' => @metrics[:buffer_available_buffer_space_ratios],
142
- 'buffer_newest_timekey' => @metrics[:buffer_newest_timekey],
143
- 'buffer_oldest_timekey' => @metrics[:buffer_oldest_timekey],
136
+ 'buffer_total_queued_size' => [@metrics[:buffer_total_queued_size]],
137
+ 'buffer_stage_length' => [@metrics[:buffer_stage_length]],
138
+ 'buffer_stage_byte_size' => [@metrics[:buffer_stage_byte_size]],
139
+ 'buffer_queue_length' => [@metrics[:buffer_queue_length]],
140
+ 'buffer_queue_byte_size' => [@metrics[:buffer_queue_byte_size]],
141
+ 'buffer_available_buffer_space_ratios' => [@metrics[:buffer_available_buffer_space_ratios]],
142
+ 'buffer_newest_timekey' => [@metrics[:buffer_newest_timekey]],
143
+ 'buffer_oldest_timekey' => [@metrics[:buffer_oldest_timekey]],
144
144
 
145
145
  # output metrics
146
- 'retry_count' => @metrics[:retry_counts],
146
+ 'retry_count' => [@metrics[:retry_counts], @metrics[:num_errors]],
147
+ # Needed since Fluentd v1.14 due to metrics extensions.
148
+ 'write_count' => [@metrics[:write_count]],
149
+ 'emit_count' => [@metrics[:emit_count]],
150
+ 'emit_records' => [@metrics[:emit_records]],
151
+ 'rollback_count' => [@metrics[:rollback_count]],
152
+ 'flush_time_count' => [@metrics[:flush_time_count]],
153
+ 'slow_flush_count' => [@metrics[:slow_flush_count]],
147
154
  }
155
+ # No needed for Fluentd v1.14 but leave as-is for backward compatibility.
148
156
  instance_vars_info = {
149
157
  num_errors: @metrics[:num_errors],
150
158
  write_count: @metrics[:write_count],
@@ -158,12 +166,14 @@ module Fluent::Plugin
158
166
  agent_info.each do |info|
159
167
  label = labels(info)
160
168
 
161
- monitor_info.each do |name, metric|
162
- if info[name]
163
- if metric.is_a?(::Prometheus::Client::Gauge)
164
- metric.set(info[name], labels: label)
165
- elsif metric.is_a?(::Prometheus::Client::Counter)
166
- metric.increment(by: info[name] - metric.get(labels: label), labels: label)
169
+ monitor_info.each do |name, metrics|
170
+ metrics.each do |metric|
171
+ if info[name]
172
+ if metric.is_a?(::Prometheus::Client::Gauge)
173
+ metric.set(info[name], labels: label)
174
+ elsif metric.is_a?(::Prometheus::Client::Counter)
175
+ metric.increment(by: info[name] - metric.get(labels: label), labels: label)
176
+ end
167
177
  end
168
178
  end
169
179
  end
@@ -85,6 +85,18 @@ module Fluent
85
85
  Fluent::Plugin::Prometheus::ExpandBuilder.new(log: log)
86
86
  end
87
87
 
88
+ def stringify_keys(hash_to_stringify)
89
+ # Adapted from: https://www.jvt.me/posts/2019/09/07/ruby-hash-keys-string-symbol/
90
+ hash_to_stringify.map do |k,v|
91
+ value_or_hash = if v.instance_of? Hash
92
+ stringify_keys(v)
93
+ else
94
+ v
95
+ end
96
+ [k.to_s, value_or_hash]
97
+ end.to_h
98
+ end
99
+
88
100
  def configure(conf)
89
101
  super
90
102
  @placeholder_values = {}
@@ -99,6 +111,7 @@ module Fluent
99
111
  'worker_id' => fluentd_worker_id,
100
112
  }
101
113
 
114
+ record = stringify_keys(record)
102
115
  placeholders = record.merge(@placeholder_values[tag])
103
116
  expander = @placeholder_expander_builder.build(placeholders)
104
117
  metrics.each do |metric|
@@ -119,6 +132,7 @@ module Fluent
119
132
  }
120
133
 
121
134
  es.each do |time, record|
135
+ record = stringify_keys(record)
122
136
  placeholders = record.merge(placeholder_values)
123
137
  expander = @placeholder_expander_builder.build(placeholders)
124
138
  metrics.each do |metric|
@@ -40,4 +40,29 @@ describe Fluent::Plugin::PrometheusOutput do
40
40
 
41
41
  it_behaves_like 'instruments record'
42
42
  end
43
+
44
+ describe '#run with symbolized keys' do
45
+ let(:message) { {:foo => 100, :bar => 100, :baz => 100, :qux => 10} }
46
+
47
+ context 'simple config' do
48
+ let(:config) {
49
+ BASE_CONFIG + %(
50
+ <metric>
51
+ name simple
52
+ type counter
53
+ desc Something foo.
54
+ key foo
55
+ </metric>
56
+ )
57
+ }
58
+
59
+ it 'adds a new counter metric' do
60
+ expect(registry.metrics.map(&:name)).not_to eq([:simple])
61
+ driver.run(default_tag: tag) { driver.feed(event_time, message) }
62
+ expect(registry.metrics.map(&:name)).to eq([:simple])
63
+ end
64
+ end
65
+
66
+ it_behaves_like 'instruments record'
67
+ end
43
68
  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: 2.0.0
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Sano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2022-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.1.4
162
+ rubygems_version: 3.3.7
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: A fluent plugin that collects metrics and exposes for Prometheus.