fluent-plugin-prometheus 2.0.0 → 2.0.3
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/.github/workflows/linux.yml +11 -3
- data/ChangeLog +12 -0
- data/fluent-plugin-prometheus.gemspec +1 -1
- data/lib/fluent/plugin/in_prometheus_output_monitor.rb +25 -15
- data/lib/fluent/plugin/prometheus.rb +14 -0
- data/spec/fluent/plugin/out_prometheus_spec.rb +25 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21b4b3d81d41fadb057a133293f2629b39961faaadcb7caebbd885c10ed344d1
|
4
|
+
data.tar.gz: dbd8aa719306aa164f373c781f568b82bee27fc44bfc88e86c4ea5d31c5ce545
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca73efb455416a5e7c022793c17ae088cd685f5751e3497a501f9af880a5f9e970dd838c939d3b61e9145c92e2a0d3acff3d61fbde35a88c7f29e52b148de5c4
|
7
|
+
data.tar.gz: 9feaab5d5b45e6e9cb1bd48ea3bc47381db6c9cc806e4782fab18df21b093f4034ca8215202e32f64cd776ea695a385f195b3b02ab22679e8b3c01b97b2bd27c
|
data/.github/workflows/linux.yml
CHANGED
@@ -1,16 +1,24 @@
|
|
1
1
|
name: linux
|
2
2
|
on:
|
3
|
-
|
4
|
-
|
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: [ '
|
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.
|
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,
|
162
|
-
|
163
|
-
if
|
164
|
-
metric.
|
165
|
-
|
166
|
-
|
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.
|
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:
|
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.
|
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.
|