logstash-output-graphite 1.0.1 → 1.0.2
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/lib/logstash/outputs/graphite.rb +7 -6
- data/logstash-output-graphite.gemspec +1 -1
- data/spec/outputs/graphite_spec.rb +7 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b6b47436f05d8903ef227740690ad1d785a93d7
|
4
|
+
data.tar.gz: 672997abc19ab7bc65e4650d7798125d2713a8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f7a13e246f7b82402fdeb8cbfd8ed3a87ed7d61e97b6f62cfd2e0e14dc137445b8284b58c083cc647787b830d1f97d4a92e4140ca29f7ab41dcf0e6e62812f
|
7
|
+
data.tar.gz: b0824e226d9b6bd324ea2988846d7416bf0248599b7edabae43f23bfc754a268b6a267ef4f8ee3af7df1c2f590435bbc17d7dce7a8de03f0bdd2cec5e57b169f
|
data/CHANGELOG.md
CHANGED
@@ -104,9 +104,10 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
104
104
|
end
|
105
105
|
end # def connect
|
106
106
|
|
107
|
-
def construct_metric_name(metric)
|
107
|
+
def construct_metric_name(event, metric)
|
108
108
|
if @metrics_format
|
109
|
-
|
109
|
+
sprinted = event.sprintf(@metrics_format)
|
110
|
+
return sprinted.gsub(METRIC_PLACEHOLDER, metric)
|
110
111
|
end
|
111
112
|
|
112
113
|
metric
|
@@ -175,15 +176,15 @@ class LogStash::Outputs::Graphite < LogStash::Outputs::Base
|
|
175
176
|
def metrics_lines_for_event(event, metric, value, timestamp)
|
176
177
|
if event[metric].is_a?(Hash)
|
177
178
|
dotify(event[metric], metric).map do |k,v|
|
178
|
-
metrics_line(k, v, timestamp)
|
179
|
+
metrics_line(event, k, v, timestamp)
|
179
180
|
end
|
180
181
|
else
|
181
|
-
metrics_line(event.sprintf(metric), event.sprintf(value).to_f, timestamp)
|
182
|
+
metrics_line(event, event.sprintf(metric), event.sprintf(value).to_f, timestamp)
|
182
183
|
end
|
183
184
|
end
|
184
185
|
|
185
|
-
def metrics_line(name, value, timestamp)
|
186
|
-
"#{construct_metric_name(name)} #{value} #{timestamp}"
|
186
|
+
def metrics_line(event, name, value, timestamp)
|
187
|
+
"#{construct_metric_name(event, name)} #{value} #{timestamp}"
|
187
188
|
end
|
188
189
|
|
189
190
|
# Take a nested ruby hash of the form {:a => {:b => 2}, c: => 3} and
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-output-graphite'
|
4
|
-
s.version = '1.0.
|
4
|
+
s.version = '1.0.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "This output allows you to pull metrics from your logs and ship them to Graphite"
|
7
7
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
@@ -31,9 +31,10 @@ describe LogStash::Outputs::Graphite do
|
|
31
31
|
"port" => port,
|
32
32
|
"fields_are_metrics" => true,
|
33
33
|
"include_metrics" => ["foo"],
|
34
|
-
"metrics_format" => "foo.
|
34
|
+
"metrics_format" => "foo.%{@host}.sys.data.*") }
|
35
35
|
|
36
|
-
let(:event) { LogStash::Event.new("foo" => "123") }
|
36
|
+
let(:event) { LogStash::Event.new("foo" => "123", "@host" => "testhost") }
|
37
|
+
let(:expected_metric_prefix) { "foo.#{event['@host']}.sys.data" }
|
37
38
|
|
38
39
|
context "match one key" do
|
39
40
|
it "should generate one element" do
|
@@ -42,17 +43,17 @@ describe LogStash::Outputs::Graphite do
|
|
42
43
|
|
43
44
|
it "should match the generated key" do
|
44
45
|
line = server.pop
|
45
|
-
expect(line).to match(
|
46
|
+
expect(line).to match(/^#{expected_metric_prefix}.foo 123.0 \d{10,}\n$/)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
50
|
context "when matching a nested hash" do
|
50
|
-
let(:event) { LogStash::Event.new("foo" => {"a" => 3, "c" => {"d" => 2}}) }
|
51
|
+
let(:event) { LogStash::Event.new("foo" => {"a" => 3, "c" => {"d" => 2}}, "@host" => "myhost") }
|
51
52
|
|
52
53
|
it "should create the proper formatted lines" do
|
53
54
|
lines = [server.pop, server.pop].sort # Put key 'a' first
|
54
|
-
expect(lines[0]).to match(
|
55
|
-
expect(lines[1]).to match(
|
55
|
+
expect(lines[0]).to match(/^#{expected_metric_prefix}.foo.a 3 \d{10,}\n$/)
|
56
|
+
expect(lines[1]).to match(/^#{expected_metric_prefix}.foo.c.d 2 \d{10,}\n$/)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|
@@ -192,6 +193,5 @@ describe LogStash::Outputs::Graphite do
|
|
192
193
|
expect(dotified).to eql("a" => 2, "5" => 4)
|
193
194
|
end
|
194
195
|
end
|
195
|
-
|
196
196
|
end
|
197
197
|
end
|