fluent-plugin-prometheus-smarter 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README.md +484 -0
- data/Rakefile +7 -0
- data/fluent-plugin-prometheus.gemspec +22 -0
- data/lib/fluent/plugin/filter_prometheus.rb +30 -0
- data/lib/fluent/plugin/in_prometheus.rb +222 -0
- data/lib/fluent/plugin/in_prometheus_monitor.rb +99 -0
- data/lib/fluent/plugin/in_prometheus_output_monitor.rb +202 -0
- data/lib/fluent/plugin/in_prometheus_tail_monitor.rb +95 -0
- data/lib/fluent/plugin/metric_prometheus.rb +71 -0
- data/lib/fluent/plugin/out_prometheus.rb +29 -0
- data/lib/fluent/plugin/prometheus.rb +296 -0
- data/lib/fluent/plugin/prometheus/placeholder_expander.rb +132 -0
- data/lib/fluent/plugin/prometheus_metrics.rb +77 -0
- data/misc/fluentd_sample.conf +170 -0
- data/misc/nginx_proxy.conf +22 -0
- data/misc/prometheus.yaml +13 -0
- data/misc/prometheus_alerts.yaml +59 -0
- data/spec/fluent/plugin/filter_prometheus_spec.rb +48 -0
- data/spec/fluent/plugin/in_prometheus_monitor_spec.rb +42 -0
- data/spec/fluent/plugin/in_prometheus_spec.rb +225 -0
- data/spec/fluent/plugin/in_prometheus_tail_monitor_spec.rb +42 -0
- data/spec/fluent/plugin/out_prometheus_spec.rb +43 -0
- data/spec/fluent/plugin/prometheus/placeholder_expander_spec.rb +110 -0
- data/spec/fluent/plugin/prometheus_metrics_spec.rb +138 -0
- data/spec/fluent/plugin/shared.rb +249 -0
- data/spec/spec_helper.rb +10 -0
- metadata +174 -0
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fluent/plugin/in_prometheus'
|
3
|
+
require 'fluent/test/driver/input'
|
4
|
+
|
5
|
+
require 'net/http'
|
6
|
+
|
7
|
+
describe Fluent::Plugin::PromMetricsAggregator do
|
8
|
+
|
9
|
+
metrics_worker_1 = %[# TYPE fluentd_status_buffer_queue_length gauge
|
10
|
+
# HELP fluentd_status_buffer_queue_length Current buffer queue length.
|
11
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="0",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
12
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="0",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
13
|
+
# TYPE fluentd_status_buffer_total_bytes gauge
|
14
|
+
# HELP fluentd_status_buffer_total_bytes Current total size of queued buffers.
|
15
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="0",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
16
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="0",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
17
|
+
# TYPE log_counter counter
|
18
|
+
# HELP log_counter the number of received logs
|
19
|
+
log_counter{worker_id="0",host="0123456789ab",tag="fluent.info"} 1.0
|
20
|
+
# HELP empty_metric A metric with no data
|
21
|
+
# TYPE empty_metric gauge
|
22
|
+
# HELP http_request_duration_seconds The HTTP request latencies in seconds.
|
23
|
+
# TYPE http_request_duration_seconds histogram
|
24
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.005"} 58
|
25
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.01"} 58
|
26
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.05"} 59
|
27
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.1"} 59
|
28
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="1"} 59
|
29
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="10"} 59
|
30
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="+Inf"} 59
|
31
|
+
http_request_duration_seconds_sum{code="200",worker_id="0",method="GET"} 0.05046115500000003
|
32
|
+
http_request_duration_seconds_count{code="200",worker_id="0",method="GET"} 59
|
33
|
+
]
|
34
|
+
|
35
|
+
metrics_worker_2 = %[# TYPE fluentd_output_status_buffer_queue_length gauge
|
36
|
+
# HELP fluentd_output_status_buffer_queue_length Current buffer queue length.
|
37
|
+
fluentd_output_status_buffer_queue_length{host="0123456789ab",worker_id="0",plugin_id="plugin-1",type="s3"} 0.0
|
38
|
+
fluentd_output_status_buffer_queue_length{host="0123456789ab",worker_id="0",plugin_id="plugin-2",type="s3"} 0.0
|
39
|
+
# TYPE fluentd_output_status_buffer_total_bytes gauge
|
40
|
+
# HELP fluentd_output_status_buffer_total_bytes Current total size of queued buffers.
|
41
|
+
fluentd_output_status_buffer_total_bytes{host="0123456789ab",worker_id="0",plugin_id="plugin-1",type="s3"} 0.0
|
42
|
+
fluentd_output_status_buffer_total_bytes{host="0123456789ab",worker_id="0",plugin_id="plugin-2",type="s3"} 0.0
|
43
|
+
]
|
44
|
+
|
45
|
+
metrics_worker_3 = %[# TYPE fluentd_status_buffer_queue_length gauge
|
46
|
+
# HELP fluentd_status_buffer_queue_length Current buffer queue length.
|
47
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="1",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
48
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="1",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
49
|
+
# TYPE fluentd_status_buffer_total_bytes gauge
|
50
|
+
# HELP fluentd_status_buffer_total_bytes Current total size of queued buffers.
|
51
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="1",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
52
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="1",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
53
|
+
# HELP http_request_duration_seconds The HTTP request latencies in seconds.
|
54
|
+
# TYPE http_request_duration_seconds histogram
|
55
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.005"} 70
|
56
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.01"} 70
|
57
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.05"} 71
|
58
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.1"} 71
|
59
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="1"} 71
|
60
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="10"} 71
|
61
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="+Inf"} 71
|
62
|
+
http_request_duration_seconds_sum{code="200",worker_id="1",method="GET"} 0.05646315600000003
|
63
|
+
http_request_duration_seconds_count{code="200",worker_id="1",method="GET"} 71
|
64
|
+
]
|
65
|
+
|
66
|
+
metrics_merged_1_and_3 = %[# TYPE fluentd_status_buffer_queue_length gauge
|
67
|
+
# HELP fluentd_status_buffer_queue_length Current buffer queue length.
|
68
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="0",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
69
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="0",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
70
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="1",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
71
|
+
fluentd_status_buffer_queue_length{host="0123456789ab",worker_id="1",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
72
|
+
# TYPE fluentd_status_buffer_total_bytes gauge
|
73
|
+
# HELP fluentd_status_buffer_total_bytes Current total size of queued buffers.
|
74
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="0",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
75
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="0",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
76
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="1",plugin_id="plugin-1",plugin_category="output",type="s3"} 0.0
|
77
|
+
fluentd_status_buffer_total_bytes{host="0123456789ab",worker_id="1",plugin_id="plugin-2",plugin_category="output",type="s3"} 0.0
|
78
|
+
# TYPE log_counter counter
|
79
|
+
# HELP log_counter the number of received logs
|
80
|
+
log_counter{worker_id="0",host="0123456789ab",tag="fluent.info"} 1.0
|
81
|
+
# HELP empty_metric A metric with no data
|
82
|
+
# TYPE empty_metric gauge
|
83
|
+
# HELP http_request_duration_seconds The HTTP request latencies in seconds.
|
84
|
+
# TYPE http_request_duration_seconds histogram
|
85
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.005"} 58
|
86
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.01"} 58
|
87
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.05"} 59
|
88
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="0.1"} 59
|
89
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="1"} 59
|
90
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="10"} 59
|
91
|
+
http_request_duration_seconds_bucket{code="200",worker_id="0",method="GET",le="+Inf"} 59
|
92
|
+
http_request_duration_seconds_sum{code="200",worker_id="0",method="GET"} 0.05046115500000003
|
93
|
+
http_request_duration_seconds_count{code="200",worker_id="0",method="GET"} 59
|
94
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.005"} 70
|
95
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.01"} 70
|
96
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.05"} 71
|
97
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="0.1"} 71
|
98
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="1"} 71
|
99
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="10"} 71
|
100
|
+
http_request_duration_seconds_bucket{code="200",worker_id="1",method="GET",le="+Inf"} 71
|
101
|
+
http_request_duration_seconds_sum{code="200",worker_id="1",method="GET"} 0.05646315600000003
|
102
|
+
http_request_duration_seconds_count{code="200",worker_id="1",method="GET"} 71
|
103
|
+
]
|
104
|
+
|
105
|
+
describe 'add_metrics' do
|
106
|
+
context '1st_metrics' do
|
107
|
+
it 'adds all fields' do
|
108
|
+
all_metrics = Fluent::Plugin::PromMetricsAggregator.new
|
109
|
+
all_metrics.add_metrics(metrics_worker_1)
|
110
|
+
result_str = all_metrics.get_metrics
|
111
|
+
|
112
|
+
expect(result_str).to eq(metrics_worker_1)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
context '2nd_metrics' do
|
116
|
+
it 'append new metrics' do
|
117
|
+
all_metrics = Fluent::Plugin::PromMetricsAggregator.new
|
118
|
+
all_metrics.add_metrics(metrics_worker_1)
|
119
|
+
all_metrics.add_metrics(metrics_worker_2)
|
120
|
+
result_str = all_metrics.get_metrics
|
121
|
+
|
122
|
+
expect(result_str).to eq(metrics_worker_1 + metrics_worker_2)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context '3rd_metrics' do
|
127
|
+
it 'append existing metrics in the right place' do
|
128
|
+
all_metrics = Fluent::Plugin::PromMetricsAggregator.new
|
129
|
+
all_metrics.add_metrics(metrics_worker_1)
|
130
|
+
all_metrics.add_metrics(metrics_worker_2)
|
131
|
+
all_metrics.add_metrics(metrics_worker_3)
|
132
|
+
result_str = all_metrics.get_metrics
|
133
|
+
|
134
|
+
expect(result_str).to eq(metrics_merged_1_and_3 + metrics_worker_2)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
|
2
|
+
BASE_CONFIG = %[
|
3
|
+
@type prometheus
|
4
|
+
]
|
5
|
+
|
6
|
+
SIMPLE_CONFIG = BASE_CONFIG + %[
|
7
|
+
<metric>
|
8
|
+
name simple_foo
|
9
|
+
type counter
|
10
|
+
desc Something foo.
|
11
|
+
key foo
|
12
|
+
</metric>
|
13
|
+
]
|
14
|
+
|
15
|
+
FULL_CONFIG = BASE_CONFIG + %[
|
16
|
+
<metric>
|
17
|
+
name full_foo
|
18
|
+
type counter
|
19
|
+
desc Something foo.
|
20
|
+
key foo
|
21
|
+
<labels>
|
22
|
+
key foo1
|
23
|
+
</labels>
|
24
|
+
</metric>
|
25
|
+
<metric>
|
26
|
+
name full_bar
|
27
|
+
type gauge
|
28
|
+
desc Something bar.
|
29
|
+
key bar
|
30
|
+
<labels>
|
31
|
+
key foo2
|
32
|
+
</labels>
|
33
|
+
</metric>
|
34
|
+
<metric>
|
35
|
+
name full_baz
|
36
|
+
type summary
|
37
|
+
desc Something baz.
|
38
|
+
key baz
|
39
|
+
<labels>
|
40
|
+
key foo3
|
41
|
+
</labels>
|
42
|
+
</metric>
|
43
|
+
<metric>
|
44
|
+
name full_qux
|
45
|
+
type histogram
|
46
|
+
desc Something qux.
|
47
|
+
key qux
|
48
|
+
buckets 0.1, 1, 5, 10
|
49
|
+
<labels>
|
50
|
+
key foo4
|
51
|
+
</labels>
|
52
|
+
</metric>
|
53
|
+
<metric>
|
54
|
+
name full_accessor1
|
55
|
+
type summary
|
56
|
+
desc Something with accessor.
|
57
|
+
key $.foo
|
58
|
+
<labels>
|
59
|
+
key foo5
|
60
|
+
</labels>
|
61
|
+
</metric>
|
62
|
+
<metric>
|
63
|
+
name full_accessor2
|
64
|
+
type counter
|
65
|
+
desc Something with accessor.
|
66
|
+
key $.foo
|
67
|
+
<labels>
|
68
|
+
key foo6
|
69
|
+
</labels>
|
70
|
+
</metric>
|
71
|
+
<labels>
|
72
|
+
test_key test_value
|
73
|
+
</labels>
|
74
|
+
]
|
75
|
+
|
76
|
+
PLACEHOLDER_CONFIG = BASE_CONFIG + %[
|
77
|
+
<metric>
|
78
|
+
name placeholder_foo
|
79
|
+
type counter
|
80
|
+
desc Something foo.
|
81
|
+
key foo
|
82
|
+
<labels>
|
83
|
+
foo ${foo}
|
84
|
+
</labels>
|
85
|
+
</metric>
|
86
|
+
<labels>
|
87
|
+
tag ${tag}
|
88
|
+
hostname ${hostname}
|
89
|
+
</labels>
|
90
|
+
]
|
91
|
+
|
92
|
+
ACCESSOR_CONFIG = BASE_CONFIG + %[
|
93
|
+
<metric>
|
94
|
+
name accessor_foo
|
95
|
+
type counter
|
96
|
+
desc Something foo.
|
97
|
+
key foo
|
98
|
+
<labels>
|
99
|
+
foo $.foo
|
100
|
+
</labels>
|
101
|
+
</metric>
|
102
|
+
]
|
103
|
+
|
104
|
+
COUNTER_WITHOUT_KEY_CONFIG = BASE_CONFIG + %[
|
105
|
+
<metric>
|
106
|
+
name without_key_foo
|
107
|
+
type counter
|
108
|
+
desc Something foo.
|
109
|
+
</metric>
|
110
|
+
]
|
111
|
+
|
112
|
+
shared_examples_for 'output configuration' do
|
113
|
+
context 'base config' do
|
114
|
+
let(:config) { BASE_CONFIG }
|
115
|
+
it { expect { driver }.not_to raise_error }
|
116
|
+
end
|
117
|
+
|
118
|
+
context 'with simple configuration' do
|
119
|
+
let(:config) { SIMPLE_CONFIG }
|
120
|
+
it { expect { driver }.not_to raise_error }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'with full configuration' do
|
124
|
+
let(:config) { FULL_CONFIG }
|
125
|
+
it { expect { driver }.not_to raise_error }
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'with placeholder configuration' do
|
129
|
+
let(:config) { PLACEHOLDER_CONFIG }
|
130
|
+
it { expect { driver }.not_to raise_error }
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'with accessor configuration' do
|
134
|
+
let(:config) { ACCESSOR_CONFIG }
|
135
|
+
it { expect { driver }.not_to raise_error }
|
136
|
+
end
|
137
|
+
|
138
|
+
describe 'with counter without key configuration' do
|
139
|
+
let(:config) { COUNTER_WITHOUT_KEY_CONFIG }
|
140
|
+
it { expect { driver }.not_to raise_error }
|
141
|
+
end
|
142
|
+
|
143
|
+
context 'with unknown type' do
|
144
|
+
let(:config) do
|
145
|
+
BASE_CONFIG + %[
|
146
|
+
<metric>
|
147
|
+
type foo
|
148
|
+
</metric>
|
149
|
+
]
|
150
|
+
end
|
151
|
+
it { expect { driver }.to raise_error(Fluent::ConfigError) }
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
shared_examples_for 'instruments record' do
|
156
|
+
before do
|
157
|
+
driver.run(default_tag: tag) { driver.feed(event_time, message) }
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'full config' do
|
161
|
+
let(:config) { FULL_CONFIG }
|
162
|
+
let(:counter) { registry.get(:full_foo) }
|
163
|
+
let(:gauge) { registry.get(:full_bar) }
|
164
|
+
let(:summary) { registry.get(:full_baz) }
|
165
|
+
let(:histogram) { registry.get(:full_qux) }
|
166
|
+
let(:summary_with_accessor) { registry.get(:full_accessor1) }
|
167
|
+
let(:counter_with_accessor) { registry.get(:full_accessor2) }
|
168
|
+
|
169
|
+
it 'adds all metrics' do
|
170
|
+
expect(registry.metrics.map(&:name)).to eq(%i[full_foo full_bar full_baz full_qux full_accessor1 full_accessor2])
|
171
|
+
expect(counter).to be_kind_of(::Prometheus::Client::Metric)
|
172
|
+
expect(gauge).to be_kind_of(::Prometheus::Client::Metric)
|
173
|
+
expect(summary).to be_kind_of(::Prometheus::Client::Metric)
|
174
|
+
expect(summary_with_accessor).to be_kind_of(::Prometheus::Client::Metric)
|
175
|
+
expect(counter_with_accessor).to be_kind_of(::Prometheus::Client::Metric)
|
176
|
+
expect(histogram).to be_kind_of(::Prometheus::Client::Metric)
|
177
|
+
end
|
178
|
+
|
179
|
+
it 'instruments counter metric' do
|
180
|
+
expect(counter.type).to eq(:counter)
|
181
|
+
expect(counter.get({test_key: 'test_value', key: 'foo1'})).to be_kind_of(Numeric)
|
182
|
+
expect(counter_with_accessor.get({test_key: 'test_value', key: 'foo6'})).to be_kind_of(Numeric)
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'instruments gauge metric' do
|
186
|
+
expect(gauge.type).to eq(:gauge)
|
187
|
+
expect(gauge.get({test_key: 'test_value', key: 'foo2'})).to eq(100)
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'instruments summary metric' do
|
191
|
+
expect(summary.type).to eq(:summary)
|
192
|
+
expect(summary.get({test_key: 'test_value', key: 'foo3'})).to be_kind_of(Hash)
|
193
|
+
expect(summary.get({test_key: 'test_value', key: 'foo3'})[0.99]).to eq(100)
|
194
|
+
expect(summary_with_accessor.get({test_key: 'test_value', key: 'foo5'})[0.99]).to eq(100)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'instruments histogram metric' do
|
198
|
+
driver.run(default_tag: tag) do
|
199
|
+
4.times { driver.feed(event_time, message) }
|
200
|
+
end
|
201
|
+
|
202
|
+
expect(histogram.type).to eq(:histogram)
|
203
|
+
expect(histogram.get({test_key: 'test_value', key: 'foo4'})).to be_kind_of(Hash)
|
204
|
+
expect(histogram.get({test_key: 'test_value', key: 'foo4'})[10]).to eq(5) # 4 + `es` in before
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
context 'placeholder config' do
|
209
|
+
let(:config) { PLACEHOLDER_CONFIG }
|
210
|
+
let(:counter) { registry.get(:placeholder_foo) }
|
211
|
+
|
212
|
+
it 'expands placeholders with record values' do
|
213
|
+
expect(registry.metrics.map(&:name)).to eq([:placeholder_foo])
|
214
|
+
expect(counter).to be_kind_of(::Prometheus::Client::Metric)
|
215
|
+
key, _ = counter.values.find {|k,v| v == 100 }
|
216
|
+
expect(key).to be_kind_of(Hash)
|
217
|
+
expect(key[:tag]).to eq(tag)
|
218
|
+
expect(key[:hostname]).to be_kind_of(String)
|
219
|
+
expect(key[:hostname]).not_to eq("${hostname}")
|
220
|
+
expect(key[:hostname]).not_to be_empty
|
221
|
+
expect(key[:foo]).to eq("100")
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
context 'accessor config' do
|
226
|
+
let(:config) { ACCESSOR_CONFIG }
|
227
|
+
let(:counter) { registry.get(:accessor_foo) }
|
228
|
+
|
229
|
+
it 'expands accessor with record values' do
|
230
|
+
expect(registry.metrics.map(&:name)).to eq([:accessor_foo])
|
231
|
+
expect(counter).to be_kind_of(::Prometheus::Client::Metric)
|
232
|
+
key, _ = counter.values.find {|k,v| v == 100 }
|
233
|
+
expect(key).to be_kind_of(Hash)
|
234
|
+
expect(key[:foo]).to eq(100)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context 'counter_without config' do
|
239
|
+
let(:config) { COUNTER_WITHOUT_KEY_CONFIG }
|
240
|
+
let(:counter) { registry.get(:without_key_foo) }
|
241
|
+
|
242
|
+
it 'just increments by 1' do
|
243
|
+
expect(registry.metrics.map(&:name)).to eq([:without_key_foo])
|
244
|
+
expect(counter).to be_kind_of(::Prometheus::Client::Metric)
|
245
|
+
_, value = counter.values.find {|k,v| k == {} }
|
246
|
+
expect(value).to eq(1)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'fluent/test/helpers'
|
4
|
+
require 'fluent/plugin/prometheus'
|
5
|
+
|
6
|
+
# Disable Test::Unit
|
7
|
+
Test::Unit::AutoRunner.need_auto_run = false
|
8
|
+
|
9
|
+
Fluent::Test.setup
|
10
|
+
include Fluent::Test::Helpers
|
metadata
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-prometheus-smarter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.8.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masahiro Sano
|
8
|
+
- Josh Minor
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-05-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.9.1
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '2'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.9.1
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: prometheus-client
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "<"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.10'
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "<"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.10'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: rspec
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
- !ruby/object:Gem::Dependency
|
91
|
+
name: test-unit
|
92
|
+
requirement: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
description: A fluent plugin that collects metrics and exposes for Prometheus.
|
105
|
+
email:
|
106
|
+
- sabottenda@gmail.com
|
107
|
+
executables: []
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- ".gitignore"
|
112
|
+
- ".rspec"
|
113
|
+
- ".travis.yml"
|
114
|
+
- Gemfile
|
115
|
+
- LICENSE
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- fluent-plugin-prometheus.gemspec
|
119
|
+
- lib/fluent/plugin/filter_prometheus.rb
|
120
|
+
- lib/fluent/plugin/in_prometheus.rb
|
121
|
+
- lib/fluent/plugin/in_prometheus_monitor.rb
|
122
|
+
- lib/fluent/plugin/in_prometheus_output_monitor.rb
|
123
|
+
- lib/fluent/plugin/in_prometheus_tail_monitor.rb
|
124
|
+
- lib/fluent/plugin/metric_prometheus.rb
|
125
|
+
- lib/fluent/plugin/out_prometheus.rb
|
126
|
+
- lib/fluent/plugin/prometheus.rb
|
127
|
+
- lib/fluent/plugin/prometheus/placeholder_expander.rb
|
128
|
+
- lib/fluent/plugin/prometheus_metrics.rb
|
129
|
+
- misc/fluentd_sample.conf
|
130
|
+
- misc/nginx_proxy.conf
|
131
|
+
- misc/prometheus.yaml
|
132
|
+
- misc/prometheus_alerts.yaml
|
133
|
+
- spec/fluent/plugin/filter_prometheus_spec.rb
|
134
|
+
- spec/fluent/plugin/in_prometheus_monitor_spec.rb
|
135
|
+
- spec/fluent/plugin/in_prometheus_spec.rb
|
136
|
+
- spec/fluent/plugin/in_prometheus_tail_monitor_spec.rb
|
137
|
+
- spec/fluent/plugin/out_prometheus_spec.rb
|
138
|
+
- spec/fluent/plugin/prometheus/placeholder_expander_spec.rb
|
139
|
+
- spec/fluent/plugin/prometheus_metrics_spec.rb
|
140
|
+
- spec/fluent/plugin/shared.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
homepage: https://github.com/jishminor/fluent-plugin-prometheus
|
143
|
+
licenses:
|
144
|
+
- Apache-2.0
|
145
|
+
metadata: {}
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubygems_version: 3.0.3
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: A fluent plugin that collects metrics and exposes for Prometheus.
|
165
|
+
test_files:
|
166
|
+
- spec/fluent/plugin/filter_prometheus_spec.rb
|
167
|
+
- spec/fluent/plugin/in_prometheus_monitor_spec.rb
|
168
|
+
- spec/fluent/plugin/in_prometheus_spec.rb
|
169
|
+
- spec/fluent/plugin/in_prometheus_tail_monitor_spec.rb
|
170
|
+
- spec/fluent/plugin/out_prometheus_spec.rb
|
171
|
+
- spec/fluent/plugin/prometheus/placeholder_expander_spec.rb
|
172
|
+
- spec/fluent/plugin/prometheus_metrics_spec.rb
|
173
|
+
- spec/fluent/plugin/shared.rb
|
174
|
+
- spec/spec_helper.rb
|