logstash-output-riemann 2.0.2 → 2.0.5

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
  SHA1:
3
- metadata.gz: d8639ad309d749fb8499e3f3d5d72cbb0341d4d4
4
- data.tar.gz: 25df7446ca9e5ad0ffe6946fbfec876031e20c6e
3
+ metadata.gz: 9da1431db2c1e9464475df74525e448bd498d77e
4
+ data.tar.gz: 059ec0b04a8c435c2bbbf25b83fb27f068dea601
5
5
  SHA512:
6
- metadata.gz: 9eb2a13e0f6d7dffdc88fa834f41f2c1d2946af63eb3f8f06fe85c0ad8458ada7ff4dacacdbc06078bc91f6fa9f5209368baf02f5a0020ebaa1170c1d0f14a72
7
- data.tar.gz: 2ab03efe04b94432a81c9a223f51f860709a2c7f4cd269779b6c7e08705dee98847b889979722497bd4f329faa11d29a96da2d5d74c49e3b3f9ef613a5717caf
6
+ metadata.gz: 02b8650ce1fd4c4942b195b73cf32fcdcef8741978feea3df9aad8547f4e75e82ea11bf7b0dc69dc3a8768f6c4a73261becdd2f04dc2a604795a3b5266f406bc
7
+ data.tar.gz: 9854d21bb97046dae22874f0c88f7dd2f7c9b2b9e07643b500af39b83cec7e8df90588cc97db667b8a6253b57e297f8fa3dcfb0e0278a1c45f13bb89bb6f5929
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 2.0.5
2
+ - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
3
+ # 2.0.4
4
+ - New dependency requirements for logstash-core for the 5.0 release
5
+ ## 2.0.3
6
+ - Fix: when using `map_fields` with `sender` hostname would not be properly set
7
+
1
8
  ## 2.0.0
2
9
  - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
10
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Logstash Plugin
2
2
 
3
+ [![Build
4
+ Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-riemann-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-riemann-unit/)
5
+
3
6
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
7
 
5
8
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
@@ -110,11 +110,11 @@ class LogStash::Outputs::Riemann < LogStash::Outputs::Base
110
110
  this_level = Hash.new
111
111
  fields.each do |key, contents|
112
112
  next if key.start_with?("@")
113
- field = parent.nil? ? key : "#{parent}.#{key}"
114
- if contents.is_a?(Hash)
115
- this_level.merge! map_fields(field, contents)
116
- else
117
- this_level[field.to_sym] = contents
113
+ field = parent.nil? ? key : "#{parent}.#{key}"
114
+ if contents.is_a?(Hash)
115
+ this_level.merge! map_fields(field, contents)
116
+ else
117
+ this_level[field.to_sym] = contents
118
118
  end
119
119
  end
120
120
  return this_level
@@ -122,10 +122,10 @@ class LogStash::Outputs::Riemann < LogStash::Outputs::Base
122
122
 
123
123
  public
124
124
  def receive(event)
125
-
125
+
126
126
 
127
127
  r_event = build_riemann_formatted_event(event)
128
-
128
+
129
129
  @logger.debug("Riemann event: ", :riemann_event => r_event)
130
130
  send_to_riemann(r_event)
131
131
  end # def receive
@@ -133,10 +133,9 @@ class LogStash::Outputs::Riemann < LogStash::Outputs::Base
133
133
  def build_riemann_formatted_event(event)
134
134
  # Let's build us an event, shall we?
135
135
  r_event = Hash.new
136
- r_event[:host] = event.sprintf(@sender)
137
- # riemann doesn't handle floats so we reduce the precision here
138
- r_event[:time] = event["@timestamp"].to_i
136
+
139
137
  r_event[:description] = event["message"]
138
+
140
139
  if @riemann_event
141
140
  @riemann_event.each do |key, val|
142
141
  if ["ttl","metric"].include?(key)
@@ -150,6 +149,9 @@ class LogStash::Outputs::Riemann < LogStash::Outputs::Base
150
149
  r_event.merge! map_fields(nil, event.to_hash)
151
150
  end
152
151
  r_event[:tags] = event["tags"] if event["tags"].is_a?(Array)
152
+ r_event[:host] = event.sprintf(@sender)
153
+ # riemann doesn't handle floats so we reduce the precision here
154
+ r_event[:time] = event["@timestamp"].to_i
153
155
 
154
156
  return r_event
155
157
  end
@@ -160,7 +162,7 @@ class LogStash::Outputs::Riemann < LogStash::Outputs::Base
160
162
  @logger.debug("Riemann client proto: #{proto_client.to_s}")
161
163
  proto_client << riemann_formatted_event
162
164
  rescue Exception => e
163
- @logger.debug("Unhandled exception", :error => e)
165
+ @logger.error("Unhandled exception", :error => e)
164
166
  end
165
167
  end # def send_to_riemann
166
168
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-riemann'
4
- s.version = '2.0.2'
4
+ s.version = '2.0.5'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Riemann is a network event stream processing system."
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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
24
24
 
25
25
  s.add_runtime_dependency 'riemann-client', ['0.2.1']
26
26
 
@@ -3,11 +3,11 @@ require "logstash/plugin"
3
3
  require "logstash/json"
4
4
 
5
5
  describe "outputs/riemann" do
6
-
6
+ let(:output) { LogStash::Plugin.lookup("output", "riemann").new }
7
+
7
8
  context "registration" do
8
9
 
9
10
  it "should register" do
10
- output = LogStash::Plugin.lookup("output", "riemann").new
11
11
  expect {output.register}.not_to raise_error
12
12
  end
13
13
 
@@ -38,7 +38,6 @@ describe "outputs/riemann" do
38
38
 
39
39
  context "receive" do
40
40
 
41
- output = LogStash::Plugin.lookup("output", "riemann").new
42
41
  data = {"message"=>"hello", "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
43
42
  event = LogStash::Event.new data
44
43
 
@@ -51,6 +50,7 @@ describe "outputs/riemann" do
51
50
 
52
51
  end
53
52
 
53
+
54
54
  context "map_fields" do
55
55
 
56
56
  context "with basic data" do
@@ -58,14 +58,12 @@ describe "outputs/riemann" do
58
58
  it "will return keys that do not start with @ sign." do
59
59
  data = {"message"=>"hello", "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
60
60
  expected_data = {:message=>"hello", :host=>"vagrant-ubuntu-trusty-64"}
61
- output = LogStash::Plugin.lookup("output", "riemann").new
62
61
  expect(output.map_fields(nil, data)).to eq expected_data
63
62
  end
64
63
 
65
64
  it "will return a hash of nested values" do
66
65
  data = {"message"=>"hello", "node_info" => {"name" => "node1", "status" => "up"}, "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
67
66
  expected_data = {:message =>"hello", :host =>"vagrant-ubuntu-trusty-64", :"node_info.name" => "node1", :"node_info.status" => "up"}
68
- output = LogStash::Plugin.lookup("output", "riemann").new
69
67
  expect(output.map_fields(nil, data)).to eq expected_data
70
68
  end
71
69
 
@@ -76,14 +74,22 @@ describe "outputs/riemann" do
76
74
 
77
75
  context "with map_fields" do
78
76
 
77
+ let(:output) { LogStash::Plugin.lookup("output", "riemann").new("map_fields" => "true") }
78
+
79
79
  it "will return symboled hash with at least :host, :time, and :description" do
80
80
  data = {"message"=>"hello", "node_info" => {"name" => "node1", "status" => "up"}, "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
81
81
  expected_data = {:time=>1433374494, :message =>"hello", :description =>"hello", :host =>"vagrant-ubuntu-trusty-64", :"node_info.name" => "node1", :"node_info.status" => "up"}
82
82
  event = LogStash::Event.new data
83
- output = LogStash::Plugin.lookup("output", "riemann").new("map_fields" => "true")
84
83
  expect(output.build_riemann_formatted_event(event)).to eq expected_data
85
84
  end
86
85
 
86
+ it "will return a symboled hash with :host value from specified field" do
87
+ data = {"test_hostname" => "node1", "message" => "hello", "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
88
+ expected_data = {:time=>1433374494, :description =>"hello", :host =>"node1", :test_hostname => "node1", :message => "hello"}
89
+ event = LogStash::Event.new data
90
+ output.sender = "%{test_hostname}"
91
+ expect(output.build_riemann_formatted_event(event)).to eq expected_data
92
+ end
87
93
  end
88
94
 
89
95
  context "without map_fields" do
@@ -92,10 +98,16 @@ describe "outputs/riemann" do
92
98
  data = {"message"=>"hello", "node_info" => {"name" => "node1", "status" => "up"}, "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
93
99
  expected_data = {:time=>1433374494, :description =>"hello", :host =>"vagrant-ubuntu-trusty-64"}
94
100
  event = LogStash::Event.new data
95
- output = LogStash::Plugin.lookup("output", "riemann").new
96
101
  expect(output.build_riemann_formatted_event(event)).to eq expected_data
97
102
  end
98
103
 
104
+ it "will return a symboled hash with :host value from specified field" do
105
+ data = {"test_hostname" => "node1", "message" => "hello", "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
106
+ expected_data = {:time=>1433374494, :description =>"hello", :host =>"node1"}
107
+ event = LogStash::Event.new data
108
+ output.sender = "%{test_hostname}"
109
+ expect(output.build_riemann_formatted_event(event)).to eq expected_data
110
+ end
99
111
  end
100
112
 
101
113
  context "with tags" do
@@ -104,11 +116,19 @@ describe "outputs/riemann" do
104
116
  data = {"tags"=> ["good_enough", "smart_enough", "doggone_it", "people_like_me"], "message"=>"hello", "node_info" => {"name" => "node1", "status" => "up"}, "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
105
117
  expected_data = {:tags => ["good_enough", "smart_enough", "doggone_it", "people_like_me"], :time=>1433374494, :description =>"hello", :host =>"vagrant-ubuntu-trusty-64"}
106
118
  event = LogStash::Event.new data
107
- output = LogStash::Plugin.lookup("output", "riemann").new
108
119
  expect(output.build_riemann_formatted_event(event)).to eq expected_data
109
120
  end
110
121
 
111
122
  end
112
123
 
124
+ context "with riemann_event" do
125
+ it "will return a symboled hash with overriden description field" do
126
+ data = {"field_a" => "foobar", "message" => "hello", "@version"=>"1", "@timestamp"=>"2015-06-03T23:34:54.076Z", "host"=>"vagrant-ubuntu-trusty-64"}
127
+ expected_data = {:time=>1433374494, :description =>"foobar", :host =>"vagrant-ubuntu-trusty-64"}
128
+ event = LogStash::Event.new data
129
+ output.riemann_event = {"description" => "%{field_a}"}
130
+ expect(output.build_riemann_formatted_event(event)).to eq expected_data
131
+ end
132
+ end
113
133
  end
114
134
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-riemann
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2016-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
- - - '>='
16
+ - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 2.0.0.beta2
19
- - - <
20
- - !ruby/object:Gem::Version
21
- version: 3.0.0
22
- name: logstash-core
18
+ version: '1.0'
19
+ name: logstash-core-plugin-api
23
20
  prerelease: false
24
21
  type: :runtime
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - '>='
28
- - !ruby/object:Gem::Version
29
- version: 2.0.0.beta2
30
- - - <
24
+ - - "~>"
31
25
  - !ruby/object:Gem::Version
32
- version: 3.0.0
26
+ version: '1.0'
33
27
  - !ruby/object:Gem::Dependency
34
28
  requirement: !ruby/object:Gem::Requirement
35
29
  requirements:
@@ -47,7 +41,7 @@ dependencies:
47
41
  - !ruby/object:Gem::Dependency
48
42
  requirement: !ruby/object:Gem::Requirement
49
43
  requirements:
50
- - - '>='
44
+ - - ">="
51
45
  - !ruby/object:Gem::Version
52
46
  version: '0'
53
47
  name: logstash-devutils
@@ -55,13 +49,13 @@ dependencies:
55
49
  type: :development
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
- - - '>='
52
+ - - ">="
59
53
  - !ruby/object:Gem::Version
60
54
  version: '0'
61
55
  - !ruby/object:Gem::Dependency
62
56
  requirement: !ruby/object:Gem::Requirement
63
57
  requirements:
64
- - - '>='
58
+ - - ">="
65
59
  - !ruby/object:Gem::Version
66
60
  version: '0'
67
61
  name: logstash-codec-plain
@@ -69,7 +63,7 @@ dependencies:
69
63
  type: :development
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
- - - '>='
66
+ - - ">="
73
67
  - !ruby/object:Gem::Version
74
68
  version: '0'
75
69
  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
@@ -99,12 +93,12 @@ require_paths:
99
93
  - lib
100
94
  required_ruby_version: !ruby/object:Gem::Requirement
101
95
  requirements:
102
- - - '>='
96
+ - - ">="
103
97
  - !ruby/object:Gem::Version
104
98
  version: '0'
105
99
  required_rubygems_version: !ruby/object:Gem::Requirement
106
100
  requirements:
107
- - - '>='
101
+ - - ">="
108
102
  - !ruby/object:Gem::Version
109
103
  version: '0'
110
104
  requirements: []