logstash-output-riemann 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/logstash/outputs/riemann.rb +23 -10
- data/logstash-output-riemann.gemspec +1 -1
- data/spec/outputs/riemann_spec.rb +43 -0
- 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: 9ddddc40b53622a112fae7d25ea1213cec31fb04e74b9cdc63e1166d1077305a
|
4
|
+
data.tar.gz: 50a5b1ad896329d8b7cd9c22abbc263a1d9e7adee5c62dd589ee9fd57b1c03d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5146f3b43a15f1fe804c1318631f6f8058dfae6dfc28aaed53c4b82debdb732572d2c10956e9649e0fb833515720219dd0573dbe43b1b228717c6029622f783
|
7
|
+
data.tar.gz: 3ce91213a6d974b4d8bad414659a6c8a8b046ad9868f9bbea461b4c6ad8c1e889388d29994ea29d7bd0e805d4f008b12b34a630a14d2fd69221059f3b8f85bf1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 3.0.6
|
2
|
+
- Fix values from "riemann_event" not overwriting those from "map_fields".
|
3
|
+
[#22](https://github.com/logstash-plugins/logstash-output-riemann/issues/22)
|
4
|
+
- Fix ttl, metric sometimes being sent as string, not float.
|
5
|
+
[#23](https://github.com/logstash-plugins/logstash-output-riemann/issues/23)
|
6
|
+
|
1
7
|
## 3.0.5
|
2
8
|
- Fix formatting in doc for conversion to --asciidoctor [#21](https://github.com/logstash-plugins/logstash-output-riemann/pull/21)
|
3
9
|
|
@@ -132,24 +132,37 @@ class LogStash::Outputs::Riemann < LogStash::Outputs::Base
|
|
132
132
|
# Let's build us an event, shall we?
|
133
133
|
r_event = Hash.new
|
134
134
|
|
135
|
+
# Always copy "message" to Riemann's "description" field.
|
135
136
|
r_event[:description] = event.get("message")
|
136
137
|
|
138
|
+
# Directly map all other fields, if requested. Note that the "message" field
|
139
|
+
# will also be mapped this way, so if it's present, it will become a
|
140
|
+
# redundant copy of "description".
|
141
|
+
if @map_fields == true
|
142
|
+
r_event.merge! map_fields(nil, event.to_hash)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Fields specified in the "riemann_event" configuration option take
|
146
|
+
# precedence over mapped fields.
|
137
147
|
if @riemann_event
|
138
148
|
@riemann_event.each do |key, val|
|
139
|
-
|
140
|
-
r_event[key.to_sym] = event.sprintf(val).to_f
|
141
|
-
else
|
142
|
-
r_event[key.to_sym] = event.sprintf(val)
|
143
|
-
end
|
149
|
+
r_event[key.to_sym] = event.sprintf(val)
|
144
150
|
end
|
145
151
|
end
|
146
|
-
|
147
|
-
|
148
|
-
|
152
|
+
|
153
|
+
# Riemann event attributes are always strings, with a few critical
|
154
|
+
# exceptions. "ttl" and "metric" should be sent as float values.
|
155
|
+
r_event[:ttl] = r_event[:ttl].to_f if r_event[:ttl]
|
156
|
+
r_event[:metric] = r_event[:metric].to_f if r_event[:metric]
|
157
|
+
|
158
|
+
# Similarly, event _time_ in Riemann was historically an integer value.
|
159
|
+
# While current Riemann versions support sub-second time resolution in the
|
160
|
+
# form of a float, we currently ensure that we send an integer value, as
|
161
|
+
# expected by Riemann versions earlier than 0.2.13.
|
162
|
+
r_event[:time] = event.timestamp.to_i
|
163
|
+
|
149
164
|
r_event[:tags] = event.get("tags") if event.get("tags").is_a?(Array)
|
150
165
|
r_event[:host] = event.sprintf(@sender)
|
151
|
-
# riemann doesn't handle floats so we reduce the precision here
|
152
|
-
r_event[:time] = event.timestamp.to_i
|
153
166
|
|
154
167
|
return r_event
|
155
168
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-riemann'
|
3
|
-
s.version = '3.0.
|
3
|
+
s.version = '3.0.6'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Sends metrics to Riemann"
|
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"
|
@@ -90,6 +90,49 @@ describe "outputs/riemann" do
|
|
90
90
|
output.sender = "%{test_hostname}"
|
91
91
|
expect(output.build_riemann_formatted_event(event)).to eq expected_data
|
92
92
|
end
|
93
|
+
|
94
|
+
it "will overwrite mapped fields with their equivalent configuration options" do
|
95
|
+
mapped_fields = {
|
96
|
+
"description" => "old description",
|
97
|
+
"metric" => 1.0,
|
98
|
+
"service" => "old service",
|
99
|
+
"state" => "old state",
|
100
|
+
"ttl" => 1,
|
101
|
+
}
|
102
|
+
|
103
|
+
configuration_options = {
|
104
|
+
"description" => "new description",
|
105
|
+
"metric" => 2.0,
|
106
|
+
"service" => "new service",
|
107
|
+
"state" => "new state",
|
108
|
+
"ttl" => 2,
|
109
|
+
}
|
110
|
+
|
111
|
+
incoming_event = LogStash::Event.new(mapped_fields)
|
112
|
+
output.riemann_event = configuration_options
|
113
|
+
outgoing_event = output.build_riemann_formatted_event(incoming_event)
|
114
|
+
|
115
|
+
expect(outgoing_event[:description]).to eq("new description")
|
116
|
+
expect(outgoing_event[:metric]).to eq(2.0)
|
117
|
+
expect(outgoing_event[:service]).to eq("new service")
|
118
|
+
expect(outgoing_event[:state]).to eq("new state")
|
119
|
+
expect(outgoing_event[:ttl]).to eq(2)
|
120
|
+
end
|
121
|
+
|
122
|
+
it "will set float values for ttl and metric from string values in fields" do
|
123
|
+
mapped_fields = {
|
124
|
+
"ttl" => "300",
|
125
|
+
"metric" => "423.5"
|
126
|
+
}
|
127
|
+
|
128
|
+
incoming_event = LogStash::Event.new(mapped_fields)
|
129
|
+
outgoing_event = output.build_riemann_formatted_event(incoming_event)
|
130
|
+
|
131
|
+
expect(outgoing_event[:ttl]).to be_a(Float)
|
132
|
+
expect(outgoing_event[:ttl]).to eq(300)
|
133
|
+
expect(outgoing_event[:metric]).to be_a(Float)
|
134
|
+
expect(outgoing_event[:metric]).to eq(423.5)
|
135
|
+
end
|
93
136
|
end
|
94
137
|
|
95
138
|
context "without map_fields" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-riemann
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|