logstash-input-beats 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a9401d85a618195a338e8faaee3287c85b1414c
4
- data.tar.gz: ef3cdd4de1c0fea567ff29b8f43037046f4421f0
3
+ metadata.gz: b1047898fca8c088bad07177c83065b172ffa397
4
+ data.tar.gz: 30c529c2f394241878c37b9228c3bf099e963ccd
5
5
  SHA512:
6
- metadata.gz: e92307aad4c185d634b0a4a41b732d88f0b8dceb50f23cbb55814e7bfde2ae1481e6de2a72b5aa71df81c297ac37856711e1653e5199b9ee725d8b4d768517d5
7
- data.tar.gz: 74c5cc5071212c503c8ed1c054c400ea662304f793edddb7eb5f17d2b15b40b2d82d381d1c95cd81823590f592b16556299785b7362ddc35dd6d1039390cdd04
6
+ metadata.gz: f6f5fec20da96051d40ba23240b459ad3f3d50440ce1f3713fdfd91af281e1c96d2fee096349c66b13570a5c43312f74b73edc01b1d75b04383c9c0b39c76bec
7
+ data.tar.gz: 1bc58dfa1626cd59b7c1c76ed25d22c7b6ee1e9268ac91e3875ca052825f4aec08769d13ce2e09f83a95d2307fcb6a97261819caf2ef255b3d0ec95c41dd8cfe
@@ -1,3 +1,5 @@
1
+ # 0.9.4
2
+ - Correctly decorate the event with the `add_field` and `tags` option from the config #12
1
3
  # 0.9.3
2
4
  - Connection#run should rescue `Broken Pipe Error` #5
3
5
  - Fix a `SystemCallErr` issue on windows when shutting down the server #9
@@ -125,21 +125,22 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
125
125
  @lumberjack.close
126
126
  end
127
127
 
128
- private
128
+ public
129
129
  def create_event(codec, map)
130
130
  # Filebeats uses the `message` key and LSF `line`
131
131
  target_field = target_field_for_codec ? map.delete(target_field_for_codec) : nil
132
132
 
133
133
  if target_field.nil?
134
- return LogStash::Event.new(map)
134
+ event = LogStash::Event.new(map)
135
+ decorate(event)
136
+ return event
135
137
  else
136
-
137
- # All codes expects to work on string
138
+ # All codecs expects to work on string
138
139
  @codec.decode(target_field.to_s) do |decoded|
139
- decorate(decoded)
140
140
  ts = coerce_ts(map.delete("@timestamp"))
141
141
  decoded["@timestamp"] = ts unless ts.nil?
142
142
  map.each { |k, v| decoded[k] = v }
143
+ decorate(decoded)
143
144
  return decoded
144
145
  end
145
146
  end
@@ -151,10 +152,10 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
151
152
  timestamp = LogStash::Timestamp.coerce(ts)
152
153
  return timestamp if timestamp
153
154
 
154
- LOGGER.warn("Unrecognized @timestamp value, setting current time to @timestamp",
155
+ @logger.warn("Unrecognized @timestamp value, setting current time to @timestamp",
155
156
  :value => ts.inspect)
156
157
  rescue LogStash::TimestampParserError => e
157
- LOGGER.warn("Error parsing @timestamp string, setting current time to @timestamp",
158
+ @logger.warn("Error parsing @timestamp string, setting current time to @timestamp",
158
159
  :value => ts.inspect, :exception => e.message)
159
160
  end
160
161
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "logstash-input-beats"
3
- s.version = "0.9.3"
3
+ s.version = "0.9.4"
4
4
  s.licenses = ["Apache License (2.0)"]
5
5
  s.summary = "Receive events using the lumberjack protocol."
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/plugin install gemname. This gem is not a stand-alone program"
@@ -72,28 +72,55 @@ describe LogStash::Inputs::Beats do
72
72
 
73
73
  describe "#processing of events" do
74
74
  subject(:beats) { LogStash::Inputs::Beats.new(config) }
75
+ let(:codec) { LogStash::Codecs::Multiline.new("pattern" => '\n', "what" => "previous") }
75
76
 
76
- let(:lines) { {"line" => "one\ntwo\n two.2\nthree\n", "tags" => ["syslog"]} }
77
-
78
- before do
79
- allow(connection).to receive(:run).and_yield(lines)
80
- beats.register
81
- expect_any_instance_of(Lumberjack::Beats::Server).to receive(:accept).and_return(connection)
77
+ let(:config) do
78
+ { "port" => port, "ssl_certificate" => certificate.ssl_cert, "ssl_key" => certificate.ssl_key,
79
+ "type" => "example", "codec" => codec }
82
80
  end
83
81
 
82
+
84
83
  context "#codecs" do
85
- let(:config) do
86
- { "port" => port, "ssl_certificate" => certificate.ssl_cert, "ssl_key" => certificate.ssl_key,
87
- "type" => "example", "codec" => codec }
88
- end
84
+ let(:lines) { {"line" => "one\ntwo\n two.2\nthree\n", "tags" => ["syslog"]} }
89
85
 
90
- let(:codec) { LogStash::Codecs::Multiline.new("pattern" => '\n', "what" => "previous") }
86
+ before do
87
+ allow(connection).to receive(:run).and_yield(lines)
88
+ beats.register
89
+ expect_any_instance_of(Lumberjack::Beats::Server).to receive(:accept).and_return(connection)
90
+ end
91
+
91
92
  it "clone the codec per connection" do
92
93
  expect(beats.codec).to receive(:clone).once
93
94
  expect(beats).to receive(:invoke) { break }
94
95
  beats.run(queue)
95
96
  end
96
97
  end
98
+
99
+ context "#create_event" do
100
+ let(:config) { super.merge({ "add_field" => { "foo" => "bar", "[@metadata][hidden]" => "secret"}, "tags" => ["bonjour"]}) }
101
+ let(:event_map) { { "hello" => "world" } }
102
+ let(:codec) { LogStash::Codecs::Plain.new }
103
+
104
+ context "without a `target_field` defined" do
105
+ it "decorates the event" do
106
+ event = beats.create_event(codec, event_map)
107
+ expect(event["foo"]).to eq("bar")
108
+ expect(event["[@metadata][hidden]"]).to eq("secret")
109
+ expect(event["tags"]).to include("bonjour")
110
+ end
111
+ end
112
+
113
+ context "with a `target_field` defined" do
114
+ let(:event_map) { super.merge({"message" => "with a field"}) }
115
+
116
+ it "decorates the event" do
117
+ event = beats.create_event(beats.codec, event_map)
118
+ expect(event["foo"]).to eq("bar")
119
+ expect(event["[@metadata][hidden]"]).to eq("secret")
120
+ expect(event["tags"]).to include("bonjour")
121
+ end
122
+ end
123
+ end
97
124
  end
98
125
 
99
126
  unless LogStash::CompatibilityLayerApiV1.is_v1?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-beats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
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-29 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core