fluent-plugin-prometheus 1.7.0 → 2.0.2
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 +32 -0
- data/ChangeLog +39 -0
- data/README.md +28 -4
- data/fluent-plugin-prometheus.gemspec +3 -3
- data/lib/fluent/plugin/in_prometheus.rb +147 -81
- data/lib/fluent/plugin/in_prometheus/async_wrapper.rb +47 -0
- data/lib/fluent/plugin/in_prometheus_monitor.rb +19 -11
- data/lib/fluent/plugin/in_prometheus_output_monitor.rb +62 -31
- data/lib/fluent/plugin/in_prometheus_tail_monitor.rb +16 -13
- data/lib/fluent/plugin/prometheus.rb +36 -23
- data/lib/fluent/plugin/prometheus/placeholder_expander.rb +132 -0
- data/spec/fluent/plugin/filter_prometheus_spec.rb +20 -10
- data/spec/fluent/plugin/in_prometheus_monitor_spec.rb +0 -1
- 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 -9
- data/spec/fluent/plugin/prometheus/placeholder_expander_spec.rb +110 -0
- data/spec/fluent/plugin/shared.rb +58 -110
- metadata +19 -11
- data/spec/fluent/plugin/prometheus_spec.rb +0 -101
@@ -1,101 +0,0 @@
|
|
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::PrometheusInput do
|
8
|
-
CONFIG = %[
|
9
|
-
type prometheus
|
10
|
-
]
|
11
|
-
|
12
|
-
LOCAL_CONFIG = %[
|
13
|
-
type prometheus
|
14
|
-
bind 127.0.0.1
|
15
|
-
]
|
16
|
-
|
17
|
-
let(:config) { CONFIG }
|
18
|
-
let(:port) { 24231 }
|
19
|
-
let(:driver) { Fluent::Test::Driver::Input.new(Fluent::Plugin::PrometheusInput).configure(config) }
|
20
|
-
|
21
|
-
describe '#configure' do
|
22
|
-
describe 'bind' do
|
23
|
-
let(:config) { CONFIG + %[
|
24
|
-
bind 127.0.0.1
|
25
|
-
] }
|
26
|
-
it 'should be configurable' do
|
27
|
-
expect(driver.instance.bind).to eq('127.0.0.1')
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'port' do
|
32
|
-
let(:config) { CONFIG + %[
|
33
|
-
port 8888
|
34
|
-
] }
|
35
|
-
it 'should be configurable' do
|
36
|
-
expect(driver.instance.port).to eq(8888)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe 'metrics_path' do
|
41
|
-
let(:config) { CONFIG + %[
|
42
|
-
metrics_path /_test
|
43
|
-
] }
|
44
|
-
it 'should be configurable' do
|
45
|
-
expect(driver.instance.metrics_path).to eq('/_test')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe '#run' do
|
51
|
-
context '/metrics' do
|
52
|
-
let(:config) { LOCAL_CONFIG }
|
53
|
-
it 'returns 200' do
|
54
|
-
driver.run(timeout: 1) do
|
55
|
-
Net::HTTP.start("127.0.0.1", port) do |http|
|
56
|
-
req = Net::HTTP::Get.new("/metrics")
|
57
|
-
res = http.request(req)
|
58
|
-
expect(res.code).to eq('200')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context '/foo' do
|
65
|
-
let(:config) { LOCAL_CONFIG }
|
66
|
-
it 'does not return 200' do
|
67
|
-
driver.run(timeout: 1) do
|
68
|
-
Net::HTTP.start("127.0.0.1", port) do |http|
|
69
|
-
req = Net::HTTP::Get.new("/foo")
|
70
|
-
res = http.request(req)
|
71
|
-
expect(res.code).not_to eq('200')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#run_multi_workers' do
|
79
|
-
context '/metrics' do
|
80
|
-
Fluent::SystemConfig.overwrite_system_config('workers' => 4) do
|
81
|
-
let(:config) { CONFIG + %[
|
82
|
-
port #{port - 2}
|
83
|
-
] }
|
84
|
-
|
85
|
-
it 'should configure port using sequential number' do
|
86
|
-
driver = Fluent::Test::Driver::Input.new(Fluent::Plugin::PrometheusInput)
|
87
|
-
driver.instance.instance_eval{ @_fluentd_worker_id = 2 }
|
88
|
-
driver.configure(config)
|
89
|
-
expect(driver.instance.port).to eq(port)
|
90
|
-
driver.run(timeout: 1) do
|
91
|
-
Net::HTTP.start("127.0.0.1", port) do |http|
|
92
|
-
req = Net::HTTP::Get.new("/metrics")
|
93
|
-
res = http.request(req)
|
94
|
-
expect(res.code).to eq('200')
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|