logstash-input-beats 7.0.11-java → 7.0.12-java

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
  SHA256:
3
- metadata.gz: 91a2f62a6f640ebda2bac7bdd3f2cd976cc771d5ed271ce9b199566096826049
4
- data.tar.gz: 9b78539e560165939deab56ab26da6b917e614eee61e716344b25d7c77fe06a3
3
+ metadata.gz: d54c774b4f05f81f9bd6cc50d15dff112e2434c61c2a66e4dbcc12786cd3d485
4
+ data.tar.gz: 6fb474a6020ff82157c6d5da0088d2d9dfbf5920fa2f9fd7332945437111a208
5
5
  SHA512:
6
- metadata.gz: 0acb89aece15fe494b90dde5fd020f77515729d85219bf01e99c4a4e94d248576c8de07d56d7e44e4e3a3ff35433e124dfc685f6c85385c31d166a38330cf1e1
7
- data.tar.gz: 91d93358b9c6459811be7ea59c62ee0c8e2b00d60b4c4ccf4093ecbdf285ef66949741a0dea66988b1b1c5b92d42c6e305e51944cad6b7a3408a04af6920cc00
6
+ metadata.gz: 047ba52cbe6b04aae7e76c57453192c5fcc7b062c20c499c6b613bb99628201782a2355331761b9b0838938e3757c5e1766a2a3ef46c728a32dd3ba9db009774
7
+ data.tar.gz: c29c9f280e16a53b6c910c95501fe1401550d5042dcfa1c1cf47353eb5c54af0575accbb32814727027af952580302b914a92b26093e2300fa95abc20efcab99
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 7.0.12
2
+ - When configured to use a port that is already in use, the failure is now propagated to the pipeline [#537](https://github.com/logstash-plugins/logstash-input-beats/pull/537)
3
+ This fixes an issue where a misconfigured input could retry indefinitely while Logstash's health report continued to report the pipeline as healthy.
4
+
1
5
  ## 7.0.11
2
6
  - Update Netty dependency to 4.1.135.Final [#567](https://github.com/logstash-plugins/logstash-input-beats/pull/567)
3
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 7.0.11
1
+ 7.0.12
@@ -202,6 +202,12 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
202
202
  @logger.info("Starting input listener", :address => "#{@host}:#{@port}")
203
203
 
204
204
  @server = create_server
205
+ begin
206
+ @server.bind()
207
+ rescue java.net.BindException => bind_exception
208
+ @server.stop rescue nil
209
+ fail LogStash::ConfigurationError, "could not bind to #{@host}:#{@port}; #{bind_exception.message}"
210
+ end
205
211
  end # def register
206
212
 
207
213
  def create_server
@@ -211,9 +217,7 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
211
217
  end
212
218
 
213
219
  def run(output_queue)
214
- message_listener = MessageListener.new(output_queue, self)
215
- @server.setMessageListener(message_listener)
216
- @server.listen
220
+ @server.run(MessageListener.new(output_queue, self))
217
221
  end # def run
218
222
 
219
223
  def stop
@@ -9,4 +9,4 @@ require_jar('io.netty', 'netty-transport', '4.1.135.Final')
9
9
  require_jar('io.netty', 'netty-resolver', '4.1.135.Final')
10
10
  require_jar('io.netty', 'netty-buffer', '4.1.135.Final')
11
11
  require_jar('io.netty', 'netty-common', '4.1.135.Final')
12
- require_jar('org.logstash.beats', 'logstash-input-beats', '7.0.11')
12
+ require_jar('org.logstash.beats', 'logstash-input-beats', '7.0.12')
data/lib/tasks/test.rake CHANGED
@@ -1,12 +1,21 @@
1
1
  # encoding: utf-8
2
- OS_PLATFORM = RbConfig::CONFIG["host_os"]
3
2
  VENDOR_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "vendor"))
4
3
 
5
4
  #TODO: Figure out better means to keep this version in sync
6
- if OS_PLATFORM == "linux"
7
- FILEBEAT_URL = "https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.19.2-linux-x86_64.tar.gz"
8
- elsif OS_PLATFORM == "darwin"
9
- FILEBEAT_URL = "https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.19.2-linux-arm64.tar.gz"
5
+ FILEBEAT_VERSION = "8.19.14"
6
+ def filebeat_url
7
+ @filebeat_url ||= begin
8
+ host_os = RbConfig::CONFIG['host_os']
9
+ host_cpu = RbConfig::CONFIG['host_cpu']
10
+
11
+ fail("unsupported OS #{host_os}") unless %w(linux darwin).include?(host_os)
12
+ fail("unsupported CPU #{host_cpu}") unless %w(aarch64 x86_64).include?(host_cpu)
13
+
14
+ # for historic reasons aarch64 artifacts for linux are labeled arm64
15
+ host_cpu = "arm64" if host_os == "linux" && host_cpu == "aarch64"
16
+
17
+ "https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-#{FILEBEAT_VERSION}-#{host_os}-#{host_cpu}.tar.gz"
18
+ end
10
19
  end
11
20
 
12
21
  require "fileutils"
@@ -37,8 +46,9 @@ namespace :test do
37
46
  FileUtils.rm_rf(download_destination)
38
47
  FileUtils.rm_rf(destination)
39
48
  FileUtils.rm_rf(File.join(VENDOR_PATH, "filebeat.tar"))
40
- puts "Filebeat: downloading from #{FILEBEAT_URL} to #{download_destination}"
41
- download(FILEBEAT_URL, download_destination)
49
+
50
+ puts "Filebeat: downloading from #{filebeat_url} to #{download_destination}"
51
+ download(filebeat_url, download_destination)
42
52
 
43
53
  untar_all(download_destination, VENDOR_PATH) { |e| e }
44
54
  end
@@ -6,6 +6,8 @@ require "logstash/inputs/beats/message_listener"
6
6
  require "logstash/instrument/namespaced_null_metric"
7
7
  require "thread"
8
8
 
9
+ require_relative "../../support/logstash_test"
10
+
9
11
  java_import java.util.HashMap
10
12
 
11
13
  class MockMessage
@@ -54,9 +56,7 @@ end
54
56
 
55
57
  shared_examples "when the message is from any libbeat" do |ecs_compatibility, host_field_name|
56
58
  let(:input) do
57
- input = LogStash::Inputs::Beats.new({ "port" => 5555, "codec" => codec, "ecs_compatibility" => "#{ecs_compatibility}" })
58
- input.register
59
- input
59
+ LogStash::Inputs::Beats.new({ "port" => BeatsInputTest.find_available_port, "codec" => codec, "ecs_compatibility" => "#{ecs_compatibility}" })
60
60
  end
61
61
 
62
62
  #Requires data modeled as Java, not Ruby since the actual code pulls from Java backed (Netty) object
@@ -124,10 +124,12 @@ describe LogStash::Inputs::Beats::MessageListener do
124
124
  let(:queue) { Queue.new }
125
125
  let(:codec) { DummyCodec.new }
126
126
  let(:input) do
127
- input = LogStash::Inputs::Beats.new({ "port" => 5555, "codec" => codec })
128
- input.register
129
- input
127
+ LogStash::Inputs::Beats.new({ "port" => BeatsInputTest.find_available_port, "codec" => codec })
128
+ end
129
+ let(:registered_input) do
130
+ input.tap(&:register)
130
131
  end
132
+ after(:each) { input.stop }
131
133
 
132
134
  let(:ip_address) { "10.0.0.1" }
133
135
  let(:remote_address) { OngoingMethodMock.new("getHostAddress", ip_address) }
@@ -135,7 +137,7 @@ describe LogStash::Inputs::Beats::MessageListener do
135
137
 
136
138
  let(:message) { MockMessage.new("abc", { "message" => "hello world"}) }
137
139
 
138
- subject { described_class.new(queue, input) }
140
+ subject { described_class.new(queue, registered_input) }
139
141
 
140
142
  before do
141
143
  subject.onNewConnection(ctx)
@@ -11,7 +11,7 @@ require "logstash/event"
11
11
  describe LogStash::Inputs::Beats do
12
12
  let(:connection) { double("connection") }
13
13
  let(:certificate) { BeatsInputTest.certificate }
14
- let(:port) { BeatsInputTest.random_port }
14
+ let(:port) { BeatsInputTest.find_available_port(host: "::") }
15
15
  let(:client_inactivity_timeout) { 400 }
16
16
  let(:event_loop_threads) { 1 + rand(4) }
17
17
  let(:executor_threads) { 1 + rand(9) }
@@ -34,11 +34,12 @@ describe LogStash::Inputs::Beats do
34
34
  context "#register" do
35
35
  context "host related configuration" do
36
36
  let(:config) { super().merge("host" => host, "port" => port) }
37
- let(:host) { "192.168.1.20" }
38
- let(:port) { 9001 }
37
+ let(:host) { BeatsInputTest.own_ip_address }
38
+ let(:port) { BeatsInputTest.find_available_port(host: host) }
39
+ after(:each) { subject.stop }
39
40
 
40
41
  it "sends the required options to the server" do
41
- expect(org.logstash.beats.Server).to receive(:new).with(plugin.id, host, port, client_inactivity_timeout, event_loop_threads, executor_threads)
42
+ expect(org.logstash.beats.Server).to receive(:new).with(plugin.id, host, port, client_inactivity_timeout, event_loop_threads, executor_threads).and_call_original
42
43
  subject.register
43
44
  end
44
45
  end
@@ -48,6 +49,21 @@ describe LogStash::Inputs::Beats do
48
49
  expect { plugin.register }.not_to raise_error
49
50
  end
50
51
 
52
+ context "when port is unavailable" do
53
+ around(:each) do |example|
54
+ BeatsInputTest.with_bound_port(port: port, &example)
55
+ end
56
+
57
+ after(:each) { subject.stop }
58
+
59
+ it "raises a helpful exception" do
60
+ expect do
61
+ plugin.register
62
+ end.to raise_error(LogStash::ConfigurationError)
63
+ .with_message(a_string_including("could not bind to #{subject.host}:#{subject.port}"))
64
+ end
65
+ end
66
+
51
67
  context "with ssl enabled" do
52
68
 
53
69
  let(:config) { { "ssl_enabled" => true, "port" => port, "ssl_key" => certificate.ssl_key, "ssl_certificate" => certificate.ssl_cert } }
@@ -377,8 +393,8 @@ describe LogStash::Inputs::Beats do
377
393
  "ecs_compatibility" => 'disabled'
378
394
  )
379
395
  end
380
- let(:host) { "192.168.1.20" }
381
- let(:port) { 9002 }
396
+ let(:host) { BeatsInputTest.own_ip_address }
397
+ let(:port) { BeatsInputTest.find_available_port(host: host) }
382
398
 
383
399
  let(:queue) { Queue.new }
384
400
  let(:event) { LogStash::Event.new }
@@ -388,11 +404,10 @@ describe LogStash::Inputs::Beats do
388
404
  before do
389
405
  @server = org.logstash.beats.Server.new(plugin.id, host, port, client_inactivity_timeout, event_loop_threads, executor_threads)
390
406
  expect( org.logstash.beats.Server ).to receive(:new).with(plugin.id, host, port, client_inactivity_timeout, event_loop_threads, executor_threads).and_return @server
391
- expect( @server ).to receive(:listen)
407
+ expect( @server ).to receive(:run) { |message_listener| @message_listener = message_listener }
392
408
 
393
409
  subject.register
394
- subject.run(queue) # listen does nothing
395
- @message_listener = @server.getMessageListener
410
+ subject.run(queue) # stub impl of run does nothing
396
411
 
397
412
  allow( ssl_engine = double('ssl_engine') ).to receive(:getSession).and_return ssl_session
398
413
  allow( ssl_handler = double('ssl-handler') ).to receive(:engine).and_return ssl_engine
@@ -30,6 +30,37 @@ module BeatsInputTest
30
30
  def random_port
31
31
  rand(2000..10000)
32
32
  end
33
+
34
+ ##
35
+ # Returns the IP address of an interface we own that is neither loopback nor multicast.
36
+ def own_ip_address
37
+ Socket.ip_address_list.lazy
38
+ .select(&:ip?)
39
+ .reject(&:ipv4_loopback?).reject(&:ipv6_loopback?)
40
+ .reject(&:ipv4_multicast?).reject(&:ipv6_multicast?)
41
+ .map(&:ip_address)
42
+ .first || fail("no serviceable IP addresses on this host: #{Socket.ip_address_list}")
43
+ end
44
+
45
+ ##
46
+ # yield the block with a port that is available
47
+ # @return [Integer]: a port that is available
48
+ def find_available_port(host:"::")
49
+ with_bound_port(host: host, &:itself)
50
+ end
51
+
52
+ ##
53
+ # Yields block with a port that is unavailable
54
+ # @yieldparam port [Integer]
55
+ # @yieldreturn [Object]
56
+ # @return [Object]
57
+ def with_bound_port(host:"::", port:0, &block)
58
+ server = TCPServer.new(host, port)
59
+
60
+ return yield(server.local_address.ip_port)
61
+ ensure
62
+ server&.close
63
+ end
33
64
  end
34
65
 
35
66
  class DummyNeverBlockedQueue < Array
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-beats
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.11
4
+ version: 7.0.12
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-06-15 00:00:00.000000000 Z
10
+ date: 2026-07-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: logstash-core-plugin-api
@@ -290,7 +290,7 @@ files:
290
290
  - vendor/jar-dependencies/io/netty/netty-transport-native-unix-common/4.1.135.Final/netty-transport-native-unix-common-4.1.135.Final.jar
291
291
  - vendor/jar-dependencies/io/netty/netty-transport/4.1.135.Final/netty-transport-4.1.135.Final.jar
292
292
  - vendor/jar-dependencies/org/javassist/javassist/3.24.0-GA/javassist-3.24.0-GA.jar
293
- - vendor/jar-dependencies/org/logstash/beats/logstash-input-beats/7.0.11/logstash-input-beats-7.0.11.jar
293
+ - vendor/jar-dependencies/org/logstash/beats/logstash-input-beats/7.0.12/logstash-input-beats-7.0.12.jar
294
294
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
295
295
  licenses:
296
296
  - Apache License (2.0)