fluent-plugin-prometheus-smarter 1.8.5 → 1.8.6
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/fluent-plugin-prometheus.gemspec +4 -4
- data/lib/fluent/plugin/out_prometheus_metric.rb +71 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1fa3d38332098758e8a5503518f0952613e248cf0bc31fef028122f5325dc51
|
4
|
+
data.tar.gz: d134b4080167f1411d603be959133d6188001481b198d59a807f8e11677f0668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8297dfaab8ac867534ece51cd1f4849c2c04fb1b4ad012274cdeb016a5bb617db78082e149fdb39f0bbf9cbb4d92d2ee42da831a511cce09dbb952c5a188ec5
|
7
|
+
data.tar.gz: 50f762bb5613a2c4ac96481ffdcfc426e430a24910d26355622fa85bf6a2229fa3ae59513ea5936412757263e9b6952ca7cf40986668ecad444db920d5a25bb3
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "fluent-plugin-prometheus-smarter"
|
3
|
-
spec.version = "1.8.
|
4
|
-
spec.authors = ["Masahiro Sano, Josh Minor"]
|
5
|
-
spec.email = ["
|
3
|
+
spec.version = "1.8.6"
|
4
|
+
spec.authors = ["Masahiro Sano", "Josh Minor"]
|
5
|
+
spec.email = ["jishminor@gmail.com"]
|
6
6
|
spec.summary = %q{A fluent plugin that collects metrics and exposes for Prometheus.}
|
7
7
|
spec.description = %q{A fluent plugin that collects metrics and exposes for Prometheus.}
|
8
|
-
spec.homepage = "https://github.com/
|
8
|
+
spec.homepage = "https://github.com/jishminor/fluent-plugin-prometheus"
|
9
9
|
spec.license = "Apache-2.0"
|
10
10
|
|
11
11
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'fluent/plugin/output'
|
2
|
+
require 'fluent/plugin/prometheus'
|
3
|
+
|
4
|
+
module Fluent::Plugin
|
5
|
+
class PrometheusOutput < Fluent::Plugin::Output
|
6
|
+
Fluent::Plugin.register_output('prometheus_metric', self)
|
7
|
+
include Fluent::Plugin::PrometheusLabelParser
|
8
|
+
include Fluent::Plugin::Prometheus
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
@registry = ::Prometheus::Client.registry
|
13
|
+
end
|
14
|
+
|
15
|
+
def multi_workers_ready?
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
config_param :key, :string
|
20
|
+
|
21
|
+
def labels(record, expander)
|
22
|
+
label = {}
|
23
|
+
labels.each do |k, v|
|
24
|
+
if v.is_a?(String)
|
25
|
+
label[k] = expander.expand(v)
|
26
|
+
else
|
27
|
+
label[k] = v.call(record)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
label
|
31
|
+
end
|
32
|
+
|
33
|
+
def configure(conf)
|
34
|
+
super
|
35
|
+
@labels = parse_labels_elements(conf)
|
36
|
+
@placeholder_values = {}
|
37
|
+
@placeholder_expander_builder = Fluent::Plugin::Prometheus.placeholder_expander(log)
|
38
|
+
@hostname = Socket.gethostname
|
39
|
+
end
|
40
|
+
|
41
|
+
def process(tag, es)
|
42
|
+
placeholder_values = {
|
43
|
+
'tag' => tag,
|
44
|
+
'hostname' => @hostname,
|
45
|
+
'worker_id' => fluentd_worker_id,
|
46
|
+
}
|
47
|
+
|
48
|
+
# Create metric if not exists
|
49
|
+
begin
|
50
|
+
gauge = registry.gauge(tag.to_sym)
|
51
|
+
rescue ::Prometheus::Client::Registry::AlreadyRegisteredError
|
52
|
+
gauge = registry.get(tag.to_sym)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Write out values in event stream to Registry
|
56
|
+
es.each do |time, record|
|
57
|
+
placeholders = record.merge(placeholder_values)
|
58
|
+
expander = @placeholder_expander_builder.build(placeholders)
|
59
|
+
if @key.is_a?(String)
|
60
|
+
value = record[@key]
|
61
|
+
else
|
62
|
+
value = @key.call(record)
|
63
|
+
end
|
64
|
+
if value
|
65
|
+
gauge.set(labels(record, expander), value)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-prometheus-smarter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Masahiro Sano
|
7
|
+
- Masahiro Sano
|
8
|
+
- Josh Minor
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
@@ -102,7 +103,7 @@ dependencies:
|
|
102
103
|
version: '0'
|
103
104
|
description: A fluent plugin that collects metrics and exposes for Prometheus.
|
104
105
|
email:
|
105
|
-
-
|
106
|
+
- jishminor@gmail.com
|
106
107
|
executables: []
|
107
108
|
extensions: []
|
108
109
|
extra_rdoc_files: []
|
@@ -121,6 +122,7 @@ files:
|
|
121
122
|
- lib/fluent/plugin/in_prometheus_output_monitor.rb
|
122
123
|
- lib/fluent/plugin/in_prometheus_tail_monitor.rb
|
123
124
|
- lib/fluent/plugin/out_prometheus.rb
|
125
|
+
- lib/fluent/plugin/out_prometheus_metric.rb
|
124
126
|
- lib/fluent/plugin/prometheus.rb
|
125
127
|
- lib/fluent/plugin/prometheus/placeholder_expander.rb
|
126
128
|
- lib/fluent/plugin/prometheus_metrics.rb
|
@@ -137,7 +139,7 @@ files:
|
|
137
139
|
- spec/fluent/plugin/prometheus_metrics_spec.rb
|
138
140
|
- spec/fluent/plugin/shared.rb
|
139
141
|
- spec/spec_helper.rb
|
140
|
-
homepage: https://github.com/
|
142
|
+
homepage: https://github.com/jishminor/fluent-plugin-prometheus
|
141
143
|
licenses:
|
142
144
|
- Apache-2.0
|
143
145
|
metadata: {}
|
@@ -156,8 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
158
|
- !ruby/object:Gem::Version
|
157
159
|
version: '0'
|
158
160
|
requirements: []
|
159
|
-
|
160
|
-
rubygems_version: 2.7.6
|
161
|
+
rubygems_version: 3.0.3
|
161
162
|
signing_key:
|
162
163
|
specification_version: 4
|
163
164
|
summary: A fluent plugin that collects metrics and exposes for Prometheus.
|