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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70f42545c6c2f2afb23084ba07f144c67ae4501cb29e0fbdfb18755039e0e151
4
- data.tar.gz: abbfce71f80d73b0584694c3fb136515cf141e1dbd270f3bdbe44b34e29792da
3
+ metadata.gz: 88f16844dd2bbb8ea29bade3d5a76b262bc1532e8ffa28589163db38751dc5a2
4
+ data.tar.gz: 786588dcdfddc1911cbcdfbe547e5f993d3664b62325e8922563d76fe0e403bf
5
5
  SHA512:
6
- metadata.gz: d85fa26f4a9854912d557834a9fcbbf26da58427ecf522b012e3815783602c67c589c112b40e69ea82fea638165cbdbb78dacb42060b0708fd844d7a98624367
7
- data.tar.gz: b2835b957093bc69bf1177232d214d99511ca4789ca197b599fbf309e06943d7bebc09f7c10e60837851741a80f3584e0f4beae47b17b3fee4fb54770b1f6cbe
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
- events << {outside.downcase => {"value" => metric_value.to_f, "labels" => labels}}
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.2.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("test")} == { "value" => 1.0, "labels" => { "a" => "b", "x" => "y" }}
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("test")} == { "value" => 1.0, "labels" => { "a" => "b" }}
61
+ insist {event.get("test_a")} == { "test" => 1.0, "labels" => { "a" => "b" }}
62
62
  end
63
63
  end
64
64
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-prometheus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bartsch