logstash-codec-prometheus 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/codecs/prometheus.rb +5 -2
- data/logstash-codec-prometheus.gemspec +1 -1
- data/spec/codecs/prometheus_spec.rb +2 -2
- 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: 88f16844dd2bbb8ea29bade3d5a76b262bc1532e8ffa28589163db38751dc5a2
|
4
|
+
data.tar.gz: 786588dcdfddc1911cbcdfbe547e5f993d3664b62325e8922563d76fe0e403bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f68ad509bbe839bbaef86dcc3cf608a91a56eda9a789a4f29011f4e51e494d044cacde9f43a5734fbdd2b01010bba648d496e1cf66591ea84ffc37ac641e47d7
|
7
|
+
data.tar.gz: 5f0e4fe6f61c66e3a074726aa541d11682413ee8d992a4afa4dfa128ed6ab3f8b77a24b3bc4667cf0986a704ed254054b9188496f46d33f9baa47a3c93893a15
|
@@ -6,7 +6,7 @@ require 'json'
|
|
6
6
|
class LogStash::Codecs::Prometheus < LogStash::Codecs::Base
|
7
7
|
config_name "prometheus"
|
8
8
|
|
9
|
-
#
|
9
|
+
# create individual events for each metric
|
10
10
|
config :multi_event, :validate => :boolean, :default => false
|
11
11
|
|
12
12
|
public
|
@@ -26,11 +26,14 @@ class LogStash::Codecs::Prometheus < LogStash::Codecs::Base
|
|
26
26
|
outside, inside = metric_name.match(/^(.+){(.+)}$/).captures
|
27
27
|
vars = inside.split(",")
|
28
28
|
labels = {}
|
29
|
+
keys = []
|
29
30
|
vars.each do |var|
|
30
31
|
key, value = var.split("=")
|
32
|
+
keys << key
|
31
33
|
labels[key.downcase] = value.gsub!(/^\"|\"?$/, "")
|
32
34
|
end
|
33
|
-
|
35
|
+
custom_metric_name = keys.unshift(outside.downcase).join('_')
|
36
|
+
events << {custom_metric_name => {outside.downcase => metric_value.to_f, "labels" => labels}}
|
34
37
|
end
|
35
38
|
end
|
36
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-codec-prometheus'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.3.0'
|
4
4
|
s.licenses = ['Apache-2.0']
|
5
5
|
s.summary = 'Reads `prometheus` formatted lines'
|
6
6
|
s.description = 'This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program'
|
@@ -49,7 +49,7 @@ describe LogStash::Codecs::Prometheus do
|
|
49
49
|
counter = 0
|
50
50
|
codec.decode("test{a=\"b\",x=\"y\"} 1\n") do |event|
|
51
51
|
insist {event.is_a?(LogStash::Event)}
|
52
|
-
insist {event.get("
|
52
|
+
insist {event.get("test_a_x")} == { "test" => 1.0, "labels" => { "a" => "b", "x" => "y" }}
|
53
53
|
counter += 1
|
54
54
|
end
|
55
55
|
insist {counter} == 1
|
@@ -58,7 +58,7 @@ describe LogStash::Codecs::Prometheus do
|
|
58
58
|
it "should return event with labels for labeled metric" do
|
59
59
|
codec.decode("test{a=\"b\"} 1\n") do |event|
|
60
60
|
insist {event.is_a?(LogStash::Event)}
|
61
|
-
insist {event.get("
|
61
|
+
insist {event.get("test_a")} == { "test" => 1.0, "labels" => { "a" => "b" }}
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|