logstash-output-prometheus 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/CONTRIBUTORS +1 -1
- data/lib/logstash/outputs/prometheus.rb +8 -6
- data/logstash-output-prometheus.gemspec +1 -1
- data/spec/outputs/prometheus_spec.rb +129 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 130b0b24895276dd2b0d14e77d3b7004e5eaeff456db0f03ad0f45d47e53e4ab
|
4
|
+
data.tar.gz: 0a1439290b627946dd5c97d01d8f34c5da5f8fd04a8d9d1c9897d8bc81c4236e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13f01ed0e935e21ee717c82eada2b3e530c7b50b9758b9edb8d988c42869ed71b012f86e75cf1bd20dec2dd0ed644392f7ea543d2ca12addd849cb2542488d86
|
7
|
+
data.tar.gz: 93d3d9ff2fd1ce56e33230513561beacb81b7b731964cea352c84178f6348e6f7340382f82a702f712cacec3a00641f8722f2f5c8167ad77c3f066c7995b12cb
|
data/CHANGELOG.md
CHANGED
data/CONTRIBUTORS
CHANGED
@@ -2,7 +2,7 @@ The following is a list of people who have contributed ideas, code, bug
|
|
2
2
|
reports, or in general have helped logstash along its way.
|
3
3
|
|
4
4
|
Contributors:
|
5
|
-
* Spencer Malone
|
5
|
+
* Spencer Malone
|
6
6
|
|
7
7
|
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
8
8
|
Logstash, and you aren't on the list above and want to be, please let us know
|
@@ -77,13 +77,15 @@ class LogStash::Outputs::Prometheus < LogStash::Outputs::Base
|
|
77
77
|
@timer.each do |metric_name, val|
|
78
78
|
val = setup_registry_labels(val)
|
79
79
|
|
80
|
-
if
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
if $metrics[port.to_s + metric_name].nil?
|
81
|
+
if val['type'] == "histogram"
|
82
|
+
metric = prom_server.histogram(metric_name.to_sym, docstring: val['description'], labels: val['labels'].keys, buckets: val['buckets'])
|
83
|
+
else
|
84
|
+
metric = prom_server.summary(metric_name.to_sym, labels: val['labels'].keys, docstring: val['description'])
|
85
|
+
end
|
85
86
|
|
86
|
-
|
87
|
+
$metrics[port.to_s + metric_name] = metric
|
88
|
+
end
|
87
89
|
end
|
88
90
|
end # def register
|
89
91
|
|
@@ -8,13 +8,21 @@ require 'net/http'
|
|
8
8
|
describe LogStash::Outputs::Prometheus do
|
9
9
|
let(:port) { rand(2000..10000) }
|
10
10
|
let(:output) { LogStash::Outputs::Prometheus.new(properties) }
|
11
|
+
let(:secondary_output) {
|
12
|
+
if secondary_properties.nil?
|
13
|
+
LogStash::Outputs::Prometheus.new(properties)
|
14
|
+
else
|
15
|
+
LogStash::Outputs::Prometheus.new(secondary_properties)
|
16
|
+
end
|
17
|
+
}
|
11
18
|
|
12
19
|
before do
|
13
20
|
output.register
|
21
|
+
secondary_output.register
|
14
22
|
end
|
15
23
|
|
16
|
-
|
17
|
-
|
24
|
+
let(:secondary_properties) do
|
25
|
+
nil
|
18
26
|
end
|
19
27
|
|
20
28
|
let(:event) do
|
@@ -23,6 +31,16 @@ describe LogStash::Outputs::Prometheus do
|
|
23
31
|
)
|
24
32
|
end
|
25
33
|
|
34
|
+
let(:secondary_event) do
|
35
|
+
if secondary_properties.nil?
|
36
|
+
LogStash::Event.new(
|
37
|
+
secondary_properties
|
38
|
+
)
|
39
|
+
else
|
40
|
+
event
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
26
44
|
shared_examples "it should expose data" do |*values|
|
27
45
|
it "should expose data" do
|
28
46
|
output.receive(event)
|
@@ -50,6 +68,35 @@ describe LogStash::Outputs::Prometheus do
|
|
50
68
|
end
|
51
69
|
end
|
52
70
|
|
71
|
+
shared_examples "it should expose data from multiple outputs" do |*values|
|
72
|
+
it "should be able to handle unique labels under the same name" do
|
73
|
+
secondary_output.receive(secondary_event)
|
74
|
+
|
75
|
+
output.receive(event)
|
76
|
+
|
77
|
+
url = URI.parse("http://localhost:#{port}/metrics")
|
78
|
+
req = Net::HTTP::Get.new(url.to_s)
|
79
|
+
|
80
|
+
attempts = 0
|
81
|
+
|
82
|
+
begin
|
83
|
+
res = Net::HTTP.start(url.host, url.port) {|http|
|
84
|
+
http.request(req)
|
85
|
+
}
|
86
|
+
rescue
|
87
|
+
attempts++
|
88
|
+
sleep(0.1)
|
89
|
+
if attempts < 10
|
90
|
+
retry
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
values.each do |value|
|
95
|
+
expect(res.body).to include(value)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
53
100
|
describe "counter behavior" do
|
54
101
|
let(:properties) {
|
55
102
|
{
|
@@ -65,7 +112,23 @@ describe LogStash::Outputs::Prometheus do
|
|
65
112
|
}
|
66
113
|
}
|
67
114
|
|
115
|
+
let(:secondary_properties) {
|
116
|
+
{
|
117
|
+
"port" => port,
|
118
|
+
"increment" => {
|
119
|
+
"basic_counter" => {
|
120
|
+
"description" => "Test",
|
121
|
+
"labels" => {
|
122
|
+
"mylabel" => "boo"
|
123
|
+
}
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
68
129
|
include_examples "it should expose data", 'basic_counter{mylabel="hi"} 1', "# TYPE basic_counter counter", "# HELP basic_counter Test"
|
130
|
+
include_examples "it should expose data from multiple outputs", 'basic_counter{mylabel="hi"} 1', 'basic_counter{mylabel="boo"} 1'
|
131
|
+
|
69
132
|
end
|
70
133
|
|
71
134
|
describe "gauge behavior" do
|
@@ -76,12 +139,32 @@ describe LogStash::Outputs::Prometheus do
|
|
76
139
|
"increment" => {
|
77
140
|
"basic_gauge" => {
|
78
141
|
"description" => "Test1",
|
142
|
+
"labels" => {
|
143
|
+
"mylabel" => "hi"
|
144
|
+
},
|
79
145
|
"type" => "gauge"
|
80
146
|
}
|
81
147
|
}
|
82
148
|
}
|
83
149
|
}
|
84
|
-
|
150
|
+
|
151
|
+
let(:secondary_properties) {
|
152
|
+
{
|
153
|
+
"port" => port,
|
154
|
+
"increment" => {
|
155
|
+
"basic_gauge" => {
|
156
|
+
"description" => "Test1",
|
157
|
+
"type" => "gauge",
|
158
|
+
"labels" => {
|
159
|
+
"mylabel" => "boo"
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
include_examples "it should expose data", 'basic_gauge{mylabel="hi"} 1.0', "# TYPE basic_gauge gauge", "# HELP basic_gauge Test1"
|
167
|
+
include_examples "it should expose data from multiple outputs", 'basic_gauge{mylabel="hi"} 1', 'basic_gauge{mylabel="boo"} 1'
|
85
168
|
end
|
86
169
|
|
87
170
|
describe "decrement" do
|
@@ -124,12 +207,32 @@ describe LogStash::Outputs::Prometheus do
|
|
124
207
|
"huh" => {
|
125
208
|
"description" => "noway",
|
126
209
|
"type" => "summary",
|
127
|
-
"value" => "11"
|
210
|
+
"value" => "11",
|
211
|
+
"labels" => {
|
212
|
+
"mylabel" => "hi"
|
213
|
+
}
|
128
214
|
}
|
129
215
|
}
|
130
216
|
}
|
131
217
|
}
|
132
|
-
|
218
|
+
|
219
|
+
let(:secondary_properties) {
|
220
|
+
{
|
221
|
+
"port" => port,
|
222
|
+
"timer" => {
|
223
|
+
"huh" => {
|
224
|
+
"description" => "noway",
|
225
|
+
"type" => "summary",
|
226
|
+
"value" => "10",
|
227
|
+
"labels" => {
|
228
|
+
"mylabel" => "boo"
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
include_examples "it should expose data", 'huh_sum{mylabel="hi"} 11.0', 'huh_count{mylabel="hi"} 1.0', "# TYPE huh summary", "# HELP huh noway"
|
235
|
+
include_examples "it should expose data from multiple outputs", 'huh_sum{mylabel="hi"} 11.0', 'huh_sum{mylabel="boo"} 10.0'
|
133
236
|
end
|
134
237
|
|
135
238
|
describe "histogram behavior" do
|
@@ -142,12 +245,32 @@ describe LogStash::Outputs::Prometheus do
|
|
142
245
|
"description" => "abe",
|
143
246
|
"type" => "histogram",
|
144
247
|
"buckets" => [1, 5, 10],
|
145
|
-
"value" => "0"
|
248
|
+
"value" => "0",
|
249
|
+
"labels" => {
|
250
|
+
"mylabel" => "hi"
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
}
|
256
|
+
let(:secondary_properties) {
|
257
|
+
{
|
258
|
+
"port" => port,
|
259
|
+
"timer" => {
|
260
|
+
"history" => {
|
261
|
+
"description" => "abe",
|
262
|
+
"type" => "histogram",
|
263
|
+
"buckets" => [1, 5, 10],
|
264
|
+
"value" => "0",
|
265
|
+
"labels" => {
|
266
|
+
"mylabel" => "boo"
|
267
|
+
}
|
146
268
|
}
|
147
269
|
}
|
148
270
|
}
|
149
271
|
}
|
150
272
|
include_examples "it should expose data", "# TYPE history histogram", "# HELP history abe"
|
273
|
+
include_examples "it should expose data from multiple outputs", 'history_sum{mylabel="hi"} 0.0', 'history_sum{mylabel="boo"} 0.0'
|
151
274
|
end
|
152
275
|
|
153
276
|
describe "sum and count" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-prometheus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spencer Malone
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|