logstash-input-udp 3.3.3 → 3.3.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/index.asciidoc +8 -1
- data/lib/logstash/inputs/udp.rb +29 -20
- data/logstash-input-udp.gemspec +1 -1
- data/spec/inputs/udp_spec.rb +37 -1
- 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: fa380c5310565f3b74449cda1e9105f3becb648783328a93aeb824d6eec25f91
|
4
|
+
data.tar.gz: 0d08f2b0646f20f2c34392a3e4d68110712d8d8a49c4ed3b454c9156dcd22d52
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5179c29aee0fcb092d9e22691863f1320c823e0e0353647569e82e132758de545dedbe6055fbebf0a22fd8e950903c30be8e223fb894cf96822e0191def2ee1e
|
7
|
+
data.tar.gz: 3efdd9cd5de25320f949454959601f8144605c6fc773c611e3a05d84b091e21097107ac68e4b574a3ed670a3197abe7b3ad39f9fd16beba1bfa56e522e3911b6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 3.3.4
|
2
|
+
- Fixed input workers exception handling and shutdown handling [#44](https://github.com/logstash-plugins/logstash-input-udp/pull/44)
|
3
|
+
|
1
4
|
## 3.3.3
|
2
5
|
- Work around jruby/jruby#5148 by cloning messages on jruby 9k, therefore resizing the underlying byte buffer
|
3
6
|
|
data/docs/index.asciidoc
CHANGED
@@ -40,6 +40,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
40
40
|
| <<plugins-{type}s-{plugin}-queue_size>> |<<number,number>>|No
|
41
41
|
| <<plugins-{type}s-{plugin}-receive_buffer_bytes>> |<<number,number>>|No
|
42
42
|
| <<plugins-{type}s-{plugin}-workers>> |<<number,number>>|No
|
43
|
+
| <<plugins-{type}s-{plugin}-source_ip_fieldname>> |<<string,string>>|No
|
43
44
|
|=======================================================================
|
44
45
|
|
45
46
|
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
@@ -101,9 +102,15 @@ Consult your operating system documentation if you need to increase this max all
|
|
101
102
|
|
102
103
|
Number of threads processing packets
|
103
104
|
|
105
|
+
[id="plugins-{type}s-{plugin}-source_ip_fieldname"]
|
106
|
+
===== `source_ip_fieldname`
|
104
107
|
|
108
|
+
* Value type is <<string,string>>
|
109
|
+
* Default value is `"host"`
|
110
|
+
|
111
|
+
The name of the field where the source IP address will be stored.
|
105
112
|
|
106
113
|
[id="plugins-{type}s-{plugin}-common-options"]
|
107
114
|
include::{include_path}/{type}.asciidoc[]
|
108
115
|
|
109
|
-
:default_codec!:
|
116
|
+
:default_codec!:
|
data/lib/logstash/inputs/udp.rb
CHANGED
@@ -38,7 +38,8 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base
|
|
38
38
|
# before packets will start dropping.
|
39
39
|
config :queue_size, :validate => :number, :default => 2000
|
40
40
|
|
41
|
-
|
41
|
+
# The name of the field where the source IP address will be stored
|
42
|
+
config :source_ip_fieldname, :validate => :string, :default => 'host'
|
42
43
|
|
43
44
|
def initialize(params)
|
44
45
|
super
|
@@ -53,14 +54,27 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base
|
|
53
54
|
def run(output_queue)
|
54
55
|
@output_queue = output_queue
|
55
56
|
|
57
|
+
@input_to_worker = SizedQueue.new(@queue_size)
|
58
|
+
metric.gauge(:queue_size, @queue_size)
|
59
|
+
metric.gauge(:workers, @workers)
|
60
|
+
|
61
|
+
@input_workers = (1..@workers).to_a.map do |i|
|
62
|
+
@logger.debug("Starting UDP worker thread", :worker => i)
|
63
|
+
Thread.new(i, @codec.clone) { |i, codec| inputworker(i, codec) }
|
64
|
+
end
|
65
|
+
|
56
66
|
begin
|
57
67
|
# udp server
|
58
68
|
udp_listener(output_queue)
|
59
69
|
rescue => e
|
60
|
-
@logger.
|
70
|
+
@logger.error("UDP listener died", :exception => e, :backtrace => e.backtrace)
|
61
71
|
@metric_errors.increment(:listener)
|
62
72
|
Stud.stoppable_sleep(5) { stop? }
|
63
73
|
retry unless stop?
|
74
|
+
ensure
|
75
|
+
# signal workers to end
|
76
|
+
@input_workers.size.times { @input_to_worker.push([:END, nil]) }
|
77
|
+
@input_workers.each { |thread| thread.join }
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|
@@ -102,14 +116,6 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base
|
|
102
116
|
@udp.bind(@host, @port)
|
103
117
|
@logger.info("UDP listener started", :address => "#{@host}:#{@port}", :receive_buffer_bytes => "#{rcvbuf}", :queue_size => "#{@queue_size}")
|
104
118
|
|
105
|
-
@input_to_worker = SizedQueue.new(@queue_size)
|
106
|
-
metric.gauge(:queue_size, @queue_size)
|
107
|
-
metric.gauge(:workers, @workers)
|
108
|
-
|
109
|
-
@input_workers = @workers.times do |i|
|
110
|
-
@logger.debug("Starting UDP worker thread", :worker => i)
|
111
|
-
Thread.new(i, @codec.clone) { |i, codec| inputworker(i, codec) }
|
112
|
-
end
|
113
119
|
|
114
120
|
while !stop?
|
115
121
|
next if IO.select([@udp], [], [], 0.5).nil?
|
@@ -134,17 +140,20 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base
|
|
134
140
|
def inputworker(number, codec)
|
135
141
|
LogStash::Util::set_thread_name("<udp.#{number}")
|
136
142
|
|
137
|
-
|
138
|
-
|
143
|
+
while true
|
144
|
+
# a worker should never terminate from an exception, only when it receives the :END symbol
|
145
|
+
begin
|
139
146
|
payload, client = @input_to_worker.pop
|
140
|
-
|
147
|
+
break if payload == :END
|
141
148
|
|
142
|
-
|
143
|
-
|
149
|
+
ip_address = client[3]
|
150
|
+
|
151
|
+
codec.decode(payload) { |event| push_decoded_event(ip_address, event) }
|
152
|
+
codec.flush { |event| push_decoded_event(ip_address, event) }
|
153
|
+
rescue => e
|
154
|
+
@logger.error("Exception in inputworker", "exception" => e, "backtrace" => e.backtrace)
|
155
|
+
@metric_errors.increment(:worker)
|
144
156
|
end
|
145
|
-
rescue => e
|
146
|
-
@logger.error("Exception in inputworker", "exception" => e, "backtrace" => e.backtrace)
|
147
|
-
@metric_errors.increment(:worker)
|
148
157
|
end
|
149
158
|
end
|
150
159
|
|
@@ -163,9 +172,9 @@ class LogStash::Inputs::Udp < LogStash::Inputs::Base
|
|
163
172
|
end
|
164
173
|
end
|
165
174
|
|
166
|
-
def push_decoded_event(
|
175
|
+
def push_decoded_event(ip_address, event)
|
167
176
|
decorate(event)
|
168
|
-
event.set(
|
177
|
+
event.set(source_ip_fieldname, ip_address) if event.get(source_ip_fieldname).nil?
|
169
178
|
@output_queue.push(event)
|
170
179
|
metric.increment(:events)
|
171
180
|
end
|
data/logstash-input-udp.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-udp'
|
4
|
-
s.version = '3.3.
|
4
|
+
s.version = '3.3.4'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Reads events over UDP"
|
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/logstash-plugin install gemname. This gem is not a stand-alone program"
|
data/spec/inputs/udp_spec.rb
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require_relative "../spec_helper"
|
3
3
|
require_relative "../support/client"
|
4
|
+
require "logstash/codecs/base"
|
4
5
|
|
5
|
-
describe LogStash::Inputs::Udp do
|
6
6
|
|
7
|
+
class LogStash::Codecs::Crash < LogStash::Codecs::Base
|
8
|
+
config_name "crash"
|
9
|
+
|
10
|
+
def decode(data)
|
11
|
+
raise("decode crash") if data == "crash"
|
12
|
+
yield LogStash::Event.new({"message" => data })
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe LogStash::Inputs::Udp do
|
7
17
|
before do
|
8
18
|
srand(RSpec.configuration.seed)
|
9
19
|
end
|
@@ -87,4 +97,30 @@ describe LogStash::Inputs::Udp do
|
|
87
97
|
it_behaves_like "an interruptible input plugin" do
|
88
98
|
# see https://github.com/elastic/logstash-devutils/blob/9c4a1fbf2b0c4547e428c5a40ed84f60aad17f97/lib/logstash/devutils/rspec/shared_examples.rb
|
89
99
|
end
|
100
|
+
|
101
|
+
describe "worker should ignore codec exception" do
|
102
|
+
# see custom "crash" codec above which raises upon decoding the "crash" straing payload
|
103
|
+
let(:config) { { "port" => port, "workers" => 1, "codec" => "crash" } }
|
104
|
+
|
105
|
+
let(:events) do
|
106
|
+
helper.input(subject, 3) do
|
107
|
+
client.send("crash")
|
108
|
+
client.send("foo")
|
109
|
+
client.send("bar")
|
110
|
+
client.send("crash")
|
111
|
+
client.send("baz")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
before(:each) do
|
116
|
+
subject.register
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should receive events been generated" do
|
120
|
+
expect(events.size).to be(3)
|
121
|
+
expect(events[0].get("message")).to match("foo")
|
122
|
+
expect(events[1].get("message")).to match("bar")
|
123
|
+
expect(events[2].get("message")).to match("baz")
|
124
|
+
end
|
125
|
+
end
|
90
126
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-udp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|