logstash-input-beats 3.1.0.beta1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +131 -0
  3. data/CONTRIBUTORS +17 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +14 -0
  6. data/NOTICE.TXT +5 -0
  7. data/PROTOCOL.md +127 -0
  8. data/README.md +98 -0
  9. data/VERSION +1 -0
  10. data/lib/logstash-input-beats_jars.rb +17 -0
  11. data/lib/logstash/inputs/beats.rb +184 -0
  12. data/lib/logstash/inputs/beats/codec_callback_listener.rb +26 -0
  13. data/lib/logstash/inputs/beats/decoded_event_transform.rb +34 -0
  14. data/lib/logstash/inputs/beats/event_transform_common.rb +48 -0
  15. data/lib/logstash/inputs/beats/message_listener.rb +96 -0
  16. data/lib/logstash/inputs/beats/raw_event_transform.rb +18 -0
  17. data/lib/logstash/inputs/beats/tls.rb +40 -0
  18. data/lib/tasks/build.rake +15 -0
  19. data/lib/tasks/test.rake +65 -0
  20. data/logstash-input-beats.gemspec +41 -0
  21. data/spec/inputs/beats/codec_callback_listener_spec.rb +33 -0
  22. data/spec/inputs/beats/decoded_event_transform_spec.rb +74 -0
  23. data/spec/inputs/beats/event_transform_common_spec.rb +11 -0
  24. data/spec/inputs/beats/message_listener_spec.rb +108 -0
  25. data/spec/inputs/beats/raw_event_transform_spec.rb +26 -0
  26. data/spec/inputs/beats/tls_spec.rb +39 -0
  27. data/spec/inputs/beats_spec.rb +99 -0
  28. data/spec/integration/filebeat_spec.rb +234 -0
  29. data/spec/integration/logstash_forwarder_spec.rb +104 -0
  30. data/spec/spec_helper.rb +14 -0
  31. data/spec/support/client_process_helpers.rb +28 -0
  32. data/spec/support/file_helpers.rb +61 -0
  33. data/spec/support/flores_extensions.rb +82 -0
  34. data/spec/support/integration_shared_context.rb +73 -0
  35. data/spec/support/logstash_test.rb +66 -0
  36. data/spec/support/shared_examples.rb +56 -0
  37. data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-annotations/2.7.5/jackson-annotations-2.7.5.jar +0 -0
  38. data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-core/2.7.5/jackson-core-2.7.5.jar +0 -0
  39. data/vendor/jar-dependencies/com/fasterxml/jackson/core/jackson-databind/2.7.5/jackson-databind-2.7.5.jar +0 -0
  40. data/vendor/jar-dependencies/com/fasterxml/jackson/module/jackson-module-afterburner/2.7.5/jackson-module-afterburner-2.7.5.jar +0 -0
  41. data/vendor/jar-dependencies/io/netty/netty-all/4.1.1.Final/netty-all-4.1.1.Final.jar +0 -0
  42. data/vendor/jar-dependencies/io/netty/netty-tcnative-boringssl-static/1.1.33.Fork17/netty-tcnative-boringssl-static-1.1.33.Fork17.jar +0 -0
  43. data/vendor/jar-dependencies/org/apache/logging/log4j/log4j-1.2-api/2.6.1/log4j-1.2-api-2.6.1.jar +0 -0
  44. data/vendor/jar-dependencies/org/apache/logging/log4j/log4j-api/2.6.1/log4j-api-2.6.1.jar +0 -0
  45. data/vendor/jar-dependencies/org/apache/logging/log4j/log4j-core/2.6.1/log4j-core-2.6.1.jar +0 -0
  46. data/vendor/jar-dependencies/org/apache/logging/log4j/log4j-slf4j-impl/2.6.1/log4j-slf4j-impl-2.6.1.jar +0 -0
  47. data/vendor/jar-dependencies/org/bouncycastle/bcpkix-jdk15on/1.54/bcpkix-jdk15on-1.54.jar +0 -0
  48. data/vendor/jar-dependencies/org/bouncycastle/bcprov-jdk15on/1.54/bcprov-jdk15on-1.54.jar +0 -0
  49. data/vendor/jar-dependencies/org/javassist/javassist/3.20.0-GA/javassist-3.20.0-GA.jar +0 -0
  50. data/vendor/jar-dependencies/org/logstash/beats/logstash-input-beats/3.1.0.beta1/logstash-input-beats-3.1.0.beta1.jar +0 -0
  51. metadata +313 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6dc83f50cea6b2105ecf0082caebe2040de2ab68
4
+ data.tar.gz: 19e6d17b3b0dd20c7664a44577d77b1bd032d2d4
5
+ SHA512:
6
+ metadata.gz: bb9d9fb478c2a53368bf2b0cdcdc58b0955017d3a54ab42f5cb27e7afd516adba6e83f48f4d822e654d80ca75013f199e27ed5f8b51989b4728a980bbda910a6
7
+ data.tar.gz: 1723f186d35d767779c1ef14273e9822de1b49841896ca56bf47f105ab19cafc34d7d958d0e65c47b19c1c8d07d331415d172f41309cb2074e5b7ff86e30b8e6
@@ -0,0 +1,131 @@
1
+ ## 3.1.0
2
+ - Rewrite of the beats input in Java using the Netty framewwork, this rewrite is meant to be backward compatible with the previous implementation
3
+ but should yield better throughput and memory usage. https://github.com/logstash-plugins/logstash-input-beats/pull/93
4
+
5
+ ## 3.0.3
6
+
7
+ - Fix an issue when parsing multiple frames received from a filebeat client using pipelining.
8
+
9
+ ## 3.0.2
10
+
11
+ - relax constrains of `logstash-devutils` see https://github.com/elastic/logstash-devutils/issues/48
12
+
13
+ ## 3.0.1
14
+
15
+ - Republish all the gems under jruby.
16
+
17
+ ## 3.0.0
18
+
19
+ - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
20
+
21
+ ## 2.2.8
22
+
23
+ - Fix #73 Bug in EventTransformCommon#codec_name, use config_name
24
+ - Add regression test for fix to #73
25
+ - Non deterministic error for the LSF integration test
26
+ - Make this plugin really a drop in replacement for the lumberjack input, so LSF can send their events to this plugin.
27
+
28
+ ## 2.2.7
29
+
30
+ - More robust test when using a random port #60
31
+ - Fix LSF integration tests #52
32
+
33
+ ## 2.2.6
34
+
35
+ - Do not use the identity map if we don't explicitly use the `multiline` codec
36
+
37
+ ## 2.2.5
38
+
39
+ - Fix failing tests introduce by the `ssl_key_passphrase` changes.
40
+ - Added an integration test for the `ssl_key_passphrase`
41
+ - Add an optional parameter for `auto_flush`
42
+
43
+ ## 2.2.4
44
+
45
+ - Fix bug where using `ssl_key_passphrase` wouldn't work
46
+
47
+ ## 2.2.2
48
+
49
+ - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
50
+
51
+ ## 2.2.1
52
+
53
+ - New dependency requirements for logstash-core for the 5.0 release
54
+
55
+ ## 2.2.0
56
+
57
+ - The server can now do client side verification by providing a list of certificate authorities and configuring the `ssl_verify_mode`,
58
+ the server can use `peer`, if the client send a certificate it will be validated. Using `force_peer` will make sure the client provide a certificate
59
+ and it will be validated with the know CA. #8
60
+
61
+ ## 2.1.4
62
+
63
+ - Change the `logger#warn` for `logger.debug` when a peer get disconnected, keep alive check from proxy can generate a lot of logs #46
64
+
65
+ ## 2.1.3
66
+
67
+ - Make sure we stop all the threads after running the tests #48
68
+
69
+ ## 2.1.2
70
+
71
+ - Catch the `java.lang.InterruptedException` in the events broker
72
+ - Give a bit more time to the Thread to be started in the test #42
73
+
74
+ ## 2.1.1
75
+
76
+ - Release a new version of the gem that doesn't included any other gems, 2.1.0 is yanked from rubygems
77
+
78
+ ## 2.1.0
79
+
80
+ - Refactor of the code to make it easier to unit test
81
+ - Fix a conncurrency error on high load on the SizeQueue #37
82
+ - Drop the internal SizeQueue to rely on Java Synchronous Queue
83
+ - Remove the majority of the nested blocks
84
+ - Move the CircuitBreaker inside an internal namespace so it doesn't conflict with the input lumberjack
85
+ - Add more debugging log statement
86
+ - Flush the codec when a disconnect happen
87
+ - Tag/Decorate the event when a shutdown occur.
88
+ - The name of the threads managed by the input beat are now meaningful.
89
+
90
+ ## 2.0.3
91
+
92
+ - Reduce the size of the gem by removing vendor jars
93
+
94
+ ## 2.0.2
95
+
96
+ - Copy the `beat.hostname` field into the `host` field for better compatibility with the other Logstash plugins #28
97
+ - Correctly merge multiple line with the multiline codec ref: #24
98
+
99
+ ## 2.0.0
100
+
101
+ - Add support for stream identity, the ID will be generated from beat.id+resource_id or beat.name + beat.source if not present #22 #13
102
+ The identity allow the multiline codec to correctly merge string from multiples files.
103
+
104
+ ## 0.9.6
105
+
106
+ - Fix an issue with rogue events created by buffered codecs #19
107
+
108
+ ## 0.9.5
109
+
110
+ - Set concurrent-ruby to 0.9.1 see https://github.com/elastic/logstash/issues/4141
111
+
112
+ ## 0.9.4
113
+
114
+ - Correctly decorate the event with the `add_field` and `tags` option from the config #12
115
+
116
+ ## 0.9.3
117
+
118
+ - Connection#run should rescue `Broken Pipe Error` #5
119
+ - Fix a `SystemCallErr` issue on windows when shutting down the server #9
120
+
121
+ ## 0.9.2
122
+
123
+ - fix an issue with the incorrectly calculated ack when the window_size was smaller than the ACK_RATIO see https://github.com/logstash-plugins/logstash-input-beats/issues/3
124
+
125
+ ## 0.9.1
126
+
127
+ - Move the ruby-lumberjack library into the plugin
128
+
129
+ ## 0.9
130
+ - Created from `logstash-input-lumberjack` version 2.0.2 https://github.com/logstash-plugins/logstash-input-lumberjack
131
+ - Use SSL off by default
@@ -0,0 +1,17 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Colin Surprenant (colinsurprenant)
6
+ * Jordan Sissel (jordansissel)
7
+ * Kurt Hurtado (kurtado)
8
+ * Nick Ethier (nickethier)
9
+ * Pier-Hugues Pellerin (ph)
10
+ * Richard Pijnenburg (electrical)
11
+ * Suyog Rao (suyograo)
12
+ * Guy Boertje (guyboertje)
13
+
14
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
15
+ Logstash, and you aren't on the list above and want to be, please let us know
16
+ and we'll make sure you're here. Contributions from folks like you are what make
17
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logstash-mass_effect.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ Copyright 2012–2016 Jordan Sissel, Elasticsearch and contributors.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
14
+
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,127 @@
1
+ # The Lumberjack Protocol
2
+
3
+ The needs that lead to this protocol are:
4
+
5
+ * Encryption and Authentication to protect
6
+ * Compression should be used to reduce bandwidth
7
+ * Round-trip latency should not damage throughput
8
+ * Application-level message acknowledgement
9
+
10
+ ## Implementation Considerations
11
+
12
+ # Lumberjack Protocol v1
13
+
14
+ ## Behavior
15
+
16
+ Sequence and ack behavior (including sliding window, etc) is similar to TCP,
17
+ but instead of bytes, messages are the base unit.
18
+
19
+ A writer with a window size of 50 events can send up to 50 unacked events
20
+ before blocking. A reader can acknowledge the 'last event' received to
21
+ support bulk acknowledgements.
22
+
23
+ Reliable, ordered byte transport is ensured by using TCP (or TLS on top), and
24
+ this protocol aims to provide reliable, application-level, message transport.
25
+
26
+ ## Encryption and Authentication
27
+
28
+ Currently this is to be handled by TLS.
29
+
30
+ ## Wire Format
31
+
32
+ ### Layering
33
+
34
+ This entire protocol is built to be layered on top of TCP or TLS.
35
+
36
+ ### Framing
37
+
38
+ 0 1 2 3
39
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40
+ +---------------+---------------+-------------------------------+
41
+ | version(1) | frame type | payload ... |
42
+ +---------------------------------------------------------------+
43
+ | payload continued... |
44
+ +---------------------------------------------------------------+
45
+
46
+ ### 'data' frame type
47
+
48
+ * SENT FROM WRITER ONLY
49
+ * frame type value: ASCII 'D' aka byte value 0x44
50
+
51
+ data is a map of string:string pairs. This is analogous to a Hash in Ruby, a
52
+ JSON map, etc, but only strings are supported at this time.
53
+
54
+ Payload:
55
+
56
+ * 32bit unsigned sequence number
57
+ * 32bit 'pair' count (how many key/value sequences follow)
58
+ * 32bit unsigned key length followed by that many bytes for the key
59
+ * 32bit unsigned value length followed by that many bytes for the value
60
+ * repeat key/value 'count' times.
61
+
62
+ Sequence number roll-over: If you receive a sequence number less than the
63
+ previous value, this signals that the sequence number has rolled over.
64
+
65
+ ### 'json' frame type
66
+
67
+ * SENT FROM WRITER ONLY
68
+ * frame type value: ASCII 'J' aka byte value 0x4a
69
+
70
+ data is json encoded.
71
+
72
+ Payload:
73
+ * 32bit unsigned sequence number
74
+ * 32bit payload length (length in bytes of embedded json document)
75
+ * 'length' bytes of json payload
76
+
77
+ Sequence number roll-over: If you receive a sequence number less than the
78
+ previous value, this signals that the sequence number has rolled over.
79
+
80
+ ### 'ack' frame type
81
+
82
+ * SENT FROM READER ONLY
83
+ * frame type value: ASCII 'A' aka byte value 0x41
84
+
85
+ Payload:
86
+
87
+ * 32bit unsigned sequence number.
88
+
89
+ Bulk acks are supported. If you receive data frames in sequence order
90
+ 1,2,3,4,5,6, you can send an ack for '6' and the writer will take this to
91
+ mean you are acknowledging all data frames before and including '6'.
92
+
93
+ ### 'window size' frame type
94
+
95
+ * SENT FROM WRITER ONLY
96
+ * frame type value: ASCII 'W' aka byte value 0x57
97
+
98
+ Payload:
99
+
100
+ * 32bit unsigned window size value in units of whole data frames.
101
+
102
+ This frame is used to tell the reader the maximum number of unacknowledged
103
+ data frames the writer will send before blocking for acks.
104
+
105
+ ### 'compressed' frame type
106
+
107
+ * SENT FROM WRITER ONLY
108
+ * frame type value: ASCII 'C' aka byte value 0x43
109
+
110
+ Payload:
111
+
112
+ * 32bit unsigned payload length
113
+ * 'length' bytes of compressed payload
114
+
115
+ This frame type allows you to compress many frames into a single compressed
116
+ envelope and is useful for efficiently compressing many small data frames.
117
+
118
+ The compressed payload MUST contain full frames only, not partial frames.
119
+ The uncompressed payload MUST be a valid frame stream by itself. As an example,
120
+ you could have 3 data frames compressed into a single 'compressed' frame type:
121
+ 1D{k,v}{k,v}1D{k,v}{k,v}1D{k,v}{k,v} - when uncompressed, you should process
122
+ the uncompressed payload as you would reading uncompressed frames from the
123
+ network.
124
+
125
+ TODO(sissel): It's likely this model is suboptimal, instead choose to
126
+ use whole-stream compression z_stream in zlib (Zlib::ZStream in ruby) might be
127
+ preferable.
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-input-beats.svg)](https://travis-ci.org/logstash-plugins/logstash-input-beats)
4
+
5
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
+
7
+ 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.
8
+
9
+ ## Documentation
10
+
11
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
12
+
13
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
14
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.1.0.beta1
@@ -0,0 +1,17 @@
1
+ # AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.
2
+
3
+ require 'jar_dependencies'
4
+ require_jar('org.apache.logging.log4j', 'log4j-1.2-api', '2.6.1')
5
+ require_jar('org.apache.logging.log4j', 'log4j-slf4j-impl', '2.6.1')
6
+ require_jar('org.bouncycastle', 'bcprov-jdk15on', '1.54')
7
+ require_jar('org.bouncycastle', 'bcpkix-jdk15on', '1.54')
8
+ require_jar('io.netty', 'netty-all', '4.1.1.Final')
9
+ require_jar('io.netty', 'netty-tcnative-boringssl-static', '1.1.33.Fork17')
10
+ require_jar('org.apache.logging.log4j', 'log4j-api', '2.6.1')
11
+ require_jar('org.apache.logging.log4j', 'log4j-core', '2.6.1')
12
+ require_jar('org.javassist', 'javassist', '3.20.0-GA')
13
+ require_jar('com.fasterxml.jackson.core', 'jackson-core', '2.7.5')
14
+ require_jar('com.fasterxml.jackson.core', 'jackson-annotations', '2.7.5')
15
+ require_jar('com.fasterxml.jackson.core', 'jackson-databind', '2.7.5')
16
+ require_jar('com.fasterxml.jackson.module', 'jackson-module-afterburner', '2.7.5')
17
+ require_jar('org.logstash.beats', 'logstash-input-beats', '3.1.0.beta1')
@@ -0,0 +1,184 @@
1
+ # encoding: utf-8
2
+ require "logstash/inputs/base"
3
+ require "logstash/namespace"
4
+ require "logstash/timestamp"
5
+ require "logstash/codecs/identity_map_codec"
6
+ require "logstash/codecs/multiline"
7
+ require "logstash/util"
8
+ require "logstash-input-beats_jars"
9
+
10
+ import "org.logstash.beats.Server"
11
+ import "org.logstash.netty.SslSimpleBuilder"
12
+ import "org.logstash.netty.PrivateKeyConverter"
13
+ import "java.io.FileInputStream"
14
+
15
+ # This input plugin enables Logstash to receive events from the
16
+ # https://www.elastic.co/products/beats[Elastic Beats] framework.
17
+ #
18
+ class LogStash::Codecs::Base
19
+ # This monkey patch add callback based
20
+ # flow to the codec until its shipped with core.
21
+ # This give greater flexibility to the implementation by
22
+ # sending more data to the actual block.
23
+ if !method_defined?(:accept)
24
+ def accept(listener)
25
+ decode(listener.data) do |event|
26
+ listener.process_event(event)
27
+ end
28
+ end
29
+ end
30
+ if !method_defined?(:auto_flush)
31
+ def auto_flush(*)
32
+ end
33
+ end
34
+ end
35
+
36
+ class LogStash::Inputs::Beats < LogStash::Inputs::Base
37
+ require "logstash/inputs/beats/codec_callback_listener"
38
+ require "logstash/inputs/beats/event_transform_common"
39
+ require "logstash/inputs/beats/decoded_event_transform"
40
+ require "logstash/inputs/beats/raw_event_transform"
41
+ require "logstash/inputs/beats/message_listener"
42
+ require "logstash/inputs/beats/tls"
43
+
44
+ config_name "beats"
45
+
46
+ default :codec, "plain"
47
+
48
+ # The IP address to listen on.
49
+ config :host, :validate => :string, :default => "0.0.0.0"
50
+
51
+ # The port to listen on.
52
+ config :port, :validate => :number, :required => true
53
+
54
+ # Events are by default sent in plain text. You can
55
+ # enable encryption by setting `ssl` to true and configuring
56
+ # the `ssl_certificate` and `ssl_key` options.
57
+ config :ssl, :validate => :boolean, :default => false
58
+
59
+ # SSL certificate to use.
60
+ config :ssl_certificate, :validate => :path
61
+
62
+ # SSL key to use.
63
+ config :ssl_key, :validate => :path
64
+
65
+ # SSL key passphrase to use.
66
+ config :ssl_key_passphrase, :validate => :password
67
+
68
+ # Validate client certificates against these authorities.
69
+ # You can define multiple files or paths. All the certificates will
70
+ # be read and added to the trust store. You need to configure the `ssl_verify_mode`
71
+ # to `peer` or `force_peer` to enable the verification.
72
+ #
73
+ # This feature only supports certificates that are directly signed by your root CA.
74
+ # Intermediate CAs are currently not supported.
75
+ #
76
+ config :ssl_certificate_authorities, :validate => :array, :default => []
77
+
78
+ # By default the server doesn't do any client verification.
79
+ #
80
+ # `peer` will make the server ask the client to provide a certificate.
81
+ # If the client provides a certificate, it will be validated.
82
+ #
83
+ # `force_peer` will make the server ask the client to provide a certificate.
84
+ # If the client doesn't provide a certificate, the connection will be closed.
85
+ #
86
+ # This option needs to be used with `ssl_certificate_authorities` and a defined list of CAs.
87
+ config :ssl_verify_mode, :validate => ["none", "peer", "force_peer"], :default => "none"
88
+
89
+ # The number of seconds before we raise a timeout.
90
+ # This option is useful to control how much time to wait if something is blocking the pipeline.
91
+ config :congestion_threshold, :validate => :number, :default => 5
92
+
93
+ # This is the default field to which the specified codec will be applied.
94
+ config :target_field_for_codec, :validate => :string, :default => "message", :deprecated => "This option is now deprecated, the plugin is now compatible with Filebeat and Logstash-Forwarder"
95
+
96
+ # The minimum TLS version allowed for the encrypted connections. The value must be one of the following:
97
+ # 1.0 for TLS 1.0, 1.1 for TLS 1.1, 1.2 for TLS 1.2
98
+ config :tls_min_version, :validate => :number, :default => TLS.min.version
99
+
100
+ # The maximum TLS version allowed for the encrypted connections. The value must be the one of the following:
101
+ # 1.0 for TLS 1.0, 1.1 for TLS 1.1, 1.2 for TLS 1.2
102
+ config :tls_max_version, :validate => :number, :default => TLS.max.version
103
+
104
+ # The list of ciphers suite to use, listed by priorities.
105
+ config :cipher_suites, :validate => :array, :default => org.logstash.netty.SslSimpleBuilder::DEFAULT_CIPHERS
106
+
107
+ def register
108
+ if !@ssl
109
+ @logger.warn("Beats input: SSL Certificate will not be used") unless @ssl_certificate.nil?
110
+ @logger.warn("Beats input: SSL Key will not be used") unless @ssl_key.nil?
111
+ elsif !ssl_configured?
112
+ raise LogStash::ConfigurationError, "Certificate or Certificate Key not configured"
113
+ end
114
+
115
+ @logger.info("Beats inputs: Starting input listener", :address => "#{@host}:#{@port}")
116
+
117
+ # wrap the configured codec to support identity stream
118
+ # from the producers if running with the multiline codec.
119
+ #
120
+ # If they dont need an identity map, codec are stateless and can be reused
121
+ # accross multiples connections.
122
+ if need_identity_map?
123
+ @codec = LogStash::Codecs::IdentityMapCodec.new(@codec)
124
+ end
125
+
126
+ @server = create_server
127
+ end # def register
128
+
129
+ def create_server
130
+ server = org.logstash.beats.Server.new(@port)
131
+ if @ssl
132
+ private_key_converter = org.logstash.netty.PrivateKeyConverter.new(ssl_key, ssl_key_passphrase)
133
+ ssl_builder = org.logstash.netty.SslSimpleBuilder.new(FileInputStream.new(ssl_certificate), private_key_converter.convert(), ssl_key_passphrase)
134
+ .setProtocols(convert_protocols)
135
+ .setCipherSuites(normalized_ciphers)
136
+
137
+ if client_authentification?
138
+ if @ssl_verify_mode.upcase == "FORCE_PEER"
139
+ ssl_builder.setVerifyMode(org.logstash.netty.SslSimpleBuilder::SslClientVerifyMode::FORCE_PEER)
140
+ end
141
+
142
+ ssl_builder.setCertificateAuthorities(@ssl_certificate_authorities)
143
+ end
144
+
145
+ server.enableSSL(ssl_builder)
146
+ end
147
+
148
+ server
149
+ end
150
+
151
+ def ssl_configured?
152
+ !(@ssl_certificate.nil? || @ssl_key.nil?)
153
+ end
154
+
155
+ def target_codec_on_field?
156
+ !@target_codec_on_field.empty?
157
+ end
158
+
159
+ def run(output_queue)
160
+ message_listener = MessageListener.new(output_queue, self)
161
+ @server.setMessageListener(message_listener)
162
+ @server.listen
163
+ end # def run
164
+
165
+ def stop
166
+ @server.stop
167
+ end
168
+
169
+ def need_identity_map?
170
+ @codec.kind_of?(LogStash::Codecs::Multiline)
171
+ end
172
+
173
+ def client_authentification?
174
+ @ssl_certificate_authorities && @ssl_certificate_authorities.size > 0
175
+ end
176
+
177
+ def normalized_ciphers
178
+ @cipher_suites.map(&:upcase)
179
+ end
180
+
181
+ def convert_protocols
182
+ TLS.get_supported(@tls_min_version..@tls_max_version).map(&:name)
183
+ end
184
+ end