fluent-plugin-prometheus 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/fluent-plugin-prometheus.gemspec +1 -1
- 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: 53ce03bc02b89a80dbb46f166e91ad0e4a71011c54dcf1b2999fe5ef24aab7b8
|
4
|
+
data.tar.gz: d8a764f2a0ba7ffeb6ae383002aef2705e0a8c7a76550d8647452bfa032edf37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4187d6c44ae90bcbcb357efe3b6502c4a62250aa61d77779ded61c80e6be76d04e33a87ade92e9b5e4684d3b7b8d8d89a3eef9d622e9824d4801fc93ee0d6ca
|
7
|
+
data.tar.gz: c9a8db411e69763e3759ac7b3b0b9b14bd4eaf64d0c33ac0b97ac33fdcfdae2bf014c1e76de13e4c400251000faf9494e0258eddd8802f052885637003392960
|
data/ChangeLog
CHANGED
@@ -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.1"
|
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.}
|
@@ -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.1
|
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-
|
11
|
+
date: 2021-04-09 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.
|
162
|
+
rubygems_version: 3.1.2
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: A fluent plugin that collects metrics and exposes for Prometheus.
|