fluent-plugin-prometheus-smarter 1.8.11 → 1.8.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-prometheus.gemspec +1 -1
- data/lib/fluent/plugin/out_prometheus_metric.rb +5 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea00296664f93726bb84de157acf0d1cad2c29bb4490f6e342e9778ddb5918ef
|
4
|
+
data.tar.gz: c4825dd44804ce93817560b2e28dc8bc5204da3de7e328c966fabd17ccc3c238
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3047e71b3e7bc4a3c9d4dc618447c7d79b9ff41da52524d63cb39cb4779a5e63e4ddff59c73f7cf769712d22f35a1645652d7c0b82f8461313ede02b7696e719
|
7
|
+
data.tar.gz: 91a1a387a7a4300535c82fd39e140bc77536854b861f7f3932f50e60061754c371f4796a7f1c2164febe355955ad8b3f0b631f9a18e6667e521877d3121f7c63
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "fluent-plugin-prometheus-smarter"
|
3
|
-
spec.version = "1.8.
|
3
|
+
spec.version = "1.8.12"
|
4
4
|
spec.authors = ["Masahiro Sano", "Josh Minor"]
|
5
5
|
spec.email = ["jishminor@gmail.com"]
|
6
6
|
spec.summary = %q{A fluent plugin that collects metrics and exposes for Prometheus.}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fluent/plugin/output'
|
2
2
|
require 'fluent/plugin/prometheus'
|
3
|
+
require 'fluent/plugin/prometheus/placeholder_expander'
|
3
4
|
|
4
5
|
module Fluent::Plugin
|
5
6
|
class PrometheusOutputMetric < Fluent::Plugin::Output
|
@@ -18,7 +19,7 @@ module Fluent::Plugin
|
|
18
19
|
|
19
20
|
config_param :key, :string
|
20
21
|
|
21
|
-
def labels(record, expander)
|
22
|
+
def labels(labels, record, expander)
|
22
23
|
label = {}
|
23
24
|
labels.each do |k, v|
|
24
25
|
if v.is_a?(String)
|
@@ -30,15 +31,11 @@ module Fluent::Plugin
|
|
30
31
|
label
|
31
32
|
end
|
32
33
|
|
33
|
-
def self.placeholder_expander(log)
|
34
|
-
Fluent::Plugin::Prometheus::ExpandBuilder.new(log: log)
|
35
|
-
end
|
36
|
-
|
37
34
|
def configure(conf)
|
38
35
|
super
|
39
36
|
@labels = parse_labels_elements(conf)
|
40
37
|
@placeholder_values = {}
|
41
|
-
@placeholder_expander_builder = Fluent::Plugin::
|
38
|
+
@placeholder_expander_builder = Fluent::Plugin::Prometheus.placeholder_expander(log)
|
42
39
|
end
|
43
40
|
|
44
41
|
def process(tag, es)
|
@@ -56,15 +53,14 @@ module Fluent::Plugin
|
|
56
53
|
rescue ::Prometheus::Client::Registry::AlreadyRegisteredError
|
57
54
|
gauge = @registry.get(tag.to_sym)
|
58
55
|
end
|
59
|
-
|
60
|
-
expander = @placeholder_expander_builder.build(placeholders)
|
56
|
+
expander = @placeholder_expander_builder.build(placeholder_values)
|
61
57
|
if @key.is_a?(String)
|
62
58
|
value = record[@key]
|
63
59
|
else
|
64
60
|
value = @key.call(record)
|
65
61
|
end
|
66
62
|
if value
|
67
|
-
gauge.set(labels(record, expander), value)
|
63
|
+
gauge.set(labels(@labels, record, expander), value)
|
68
64
|
end
|
69
65
|
end
|
70
66
|
end
|