logstash-input-kafka 4.2.0 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -8
- data/README.md +13 -1
- data/lib/logstash/inputs/kafka.rb +70 -72
- data/logstash-input-kafka.gemspec +4 -3
- data/spec/integration/inputs/kafka_spec.rb +35 -85
- data/spec/unit/inputs/kafka_spec.rb +2 -2
- metadata +19 -17
- data/lib/log4j/log4j/1.2.17/log4j-1.2.17.jar +0 -0
- data/lib/net/jpountz/lz4/lz4/1.2.0/lz4-1.2.0.jar +0 -0
- data/lib/org/apache/kafka/kafka-clients/0.9.0.1/kafka-clients-0.9.0.1.jar +0 -0
- data/lib/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar +0 -0
- data/lib/org/slf4j/slf4j-log4j12/1.7.13/slf4j-log4j12-1.7.13.jar +0 -0
- data/lib/org/xerial/snappy/snappy-java/1.1.1.7/snappy-java-1.1.1.7.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/kafka-clients-0.9.0.1.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/log4j-1.2.17.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/lz4-1.2.0.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/slf4j-api-1.7.6.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/slf4j-log4j12-1.7.13.jar +0 -0
- data/vendor/jar-dependencies/runtime-jars/snappy-java-1.1.1.7.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f496e94c2acee0bbb82357e17efe952416381c4c
|
4
|
+
data.tar.gz: 19279054c88de9ecc57dedab85c1e584afd9f160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b3ae71f305fe402aa9dbafdb815ace949445e90168b310f2b35f90cf68d83d5b4ec69389e61d3950e897b3b8c62f24126cc2995f98b6ada301b50641d495a00
|
7
|
+
data.tar.gz: 3eb69a86fe5377bc4d348b601db819b76d1ae296ec44fe761a98db2629eae194a34590612f939f88e270d6cf5fc66b227d5ba97cc2c2ad5e129eee6944f863ff
|
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
##
|
2
|
-
-
|
3
|
-
- Restored event decorators which adds metadata.
|
1
|
+
## 5.0.1
|
2
|
+
- Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
|
4
3
|
|
5
|
-
##
|
6
|
-
-
|
7
|
-
|
8
|
-
## 4.1.0
|
9
|
-
- fix: Really support Kafka 0.9 for LS 5.x, logging changes broke 4.0.0
|
4
|
+
## 5.0.0
|
5
|
+
- Support for Kafka 0.10 which is not backward compatible with 0.9 broker.
|
10
6
|
|
11
7
|
## 4.0.0
|
12
8
|
- Republish all the gems under jruby.
|
data/README.md
CHANGED
@@ -6,6 +6,18 @@ This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
|
6
6
|
|
7
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
8
|
|
9
|
+
## Kafka Compatibility
|
10
|
+
|
11
|
+
Here's a table that describes the compatibility matrix for Kafka Broker support. Please remember that it is good advice to upgrade brokers before consumers/producers since brokers target backwards compatibility. The 0.9 broker will work with both the 0.8 consumer and 0.9 consumer APIs but not the other way around.
|
12
|
+
|
13
|
+
| Kafka Broker Version | Logstash Version | Input Plugin | Output Plugin | Why? |
|
14
|
+
|:---------------:|:------------------:|:--------------:|:---------------:|:------|
|
15
|
+
| 0.8 | 2.0 - 2.x | < 3.0.0 | <3.0.0 | Legacy, 0.8 is still popular |
|
16
|
+
| 0.9 | 2.0 - 2.3.x | 3.0.0 | 3.0.0 | Intermediate release before 0.10 that works with old Ruby Event API `[]` |
|
17
|
+
| 0.9 | 2.4, 5.0 | 4.0.0 | 4.0.0 | Intermediate release before 0.10 with new get/set API |
|
18
|
+
| 0.10 | 2.4, 5.0 | 5.0.0 | 5.0.0 | Track latest Kafka release. Not compatible with 0.9 broker |
|
19
|
+
|
20
|
+
|
9
21
|
## Documentation
|
10
22
|
|
11
23
|
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/).
|
@@ -95,4 +107,4 @@ Programming is not a required skill. Whatever you've seen about open source and
|
|
95
107
|
|
96
108
|
It is more important to the community that you are able to contribute.
|
97
109
|
|
98
|
-
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
110
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -5,10 +5,22 @@ require 'java'
|
|
5
5
|
require 'logstash-input-kafka_jars.rb'
|
6
6
|
|
7
7
|
# This input will read events from a Kafka topic. It uses the the newly designed
|
8
|
-
# 0.
|
9
|
-
# provided by Kafka to read messages from the broker.
|
8
|
+
# 0.10 version of consumer API provided by Kafka to read messages from the broker.
|
10
9
|
#
|
11
|
-
#
|
10
|
+
# Here's a compatibility matrix that shows the Kafka broker and client versions that are compatible with each combination
|
11
|
+
# of Logstash and the Kafka input plugin:
|
12
|
+
#
|
13
|
+
# [options="header"]
|
14
|
+
# |==========================================================
|
15
|
+
# |Kafka Broker Version |Kafka Client Version |Logstash Version |Plugin Version |Why?
|
16
|
+
# |0.8 |0.8 |2.0.0 - 2.x.x |<3.0.0 |Legacy, 0.8 is still popular
|
17
|
+
# |0.9 |0.9 |2.0.0 - 2.3.x | 3.x.x |Works with the old Ruby Event API (`event['product']['price'] = 10`)
|
18
|
+
# |0.9 |0.9 |2.4.0 - 5.0.x | 4.x.x |Works with the new getter/setter APIs (`event.set('[product][price]', 10)`)
|
19
|
+
# |0.10 |0.10 |2.4.0 - 5.0.x | 5.x.x |Not compatible with the 0.9 broker
|
20
|
+
# |==========================================================
|
21
|
+
#
|
22
|
+
# NOTE: It's a good idea to upgrade brokers before consumers/producers because brokers target backwards compatibility.
|
23
|
+
# For example, the 0.9 broker will work with both the 0.8 consumer and 0.9 consumer APIs, but not the other way around.
|
12
24
|
#
|
13
25
|
# The Logstash Kafka consumer handles group management and uses the default offset management
|
14
26
|
# strategy using Kafka topics.
|
@@ -16,9 +28,9 @@ require 'logstash-input-kafka_jars.rb'
|
|
16
28
|
# Logstash instances by default form a single logical group to subscribe to Kafka topics
|
17
29
|
# Each Logstash Kafka consumer can run multiple threads to increase read throughput. Alternatively,
|
18
30
|
# you could run multiple Logstash instances with the same `group_id` to spread the load across
|
19
|
-
# physical machines. Messages in a topic will be distributed to all Logstash instances with
|
31
|
+
# physical machines. Messages in a topic will be distributed to all Logstash instances with
|
20
32
|
# the same `group_id`.
|
21
|
-
#
|
33
|
+
#
|
22
34
|
# Ideally you should have as many threads as the number of partitions for a perfect balance --
|
23
35
|
# more threads than partitions means that some threads will be idle
|
24
36
|
#
|
@@ -26,7 +38,7 @@ require 'logstash-input-kafka_jars.rb'
|
|
26
38
|
#
|
27
39
|
# Kafka consumer configuration: http://kafka.apache.org/documentation.html#consumerconfigs
|
28
40
|
#
|
29
|
-
# This version also adds support for SSL/TLS security connection to Kafka. By default SSL is
|
41
|
+
# This version also adds support for SSL/TLS security connection to Kafka. By default SSL is
|
30
42
|
# disabled but can be turned on as needed.
|
31
43
|
#
|
32
44
|
class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
@@ -35,7 +47,7 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
35
47
|
default :codec, 'plain'
|
36
48
|
|
37
49
|
# The frequency in milliseconds that the consumer offsets are committed to Kafka.
|
38
|
-
config :auto_commit_interval_ms, :validate => :string, :default => "
|
50
|
+
config :auto_commit_interval_ms, :validate => :string, :default => "5000"
|
39
51
|
# What to do when there is no initial offset in Kafka or if an offset is out of range:
|
40
52
|
#
|
41
53
|
# * earliest: automatically reset the offset to the earliest offset
|
@@ -43,86 +55,92 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
43
55
|
# * none: throw exception to the consumer if no previous offset is found for the consumer's group
|
44
56
|
# * anything else: throw exception to the consumer.
|
45
57
|
config :auto_offset_reset, :validate => :string
|
46
|
-
# A list of URLs to use for establishing the initial connection to the cluster.
|
47
|
-
# This list should be in the form of `host1:port1,host2:port2` These urls are just used
|
48
|
-
# for the initial connection to discover the full cluster membership (which may change dynamically)
|
49
|
-
# so this list need not contain the full set of servers (you may want more than one, though, in
|
58
|
+
# A list of URLs to use for establishing the initial connection to the cluster.
|
59
|
+
# This list should be in the form of `host1:port1,host2:port2` These urls are just used
|
60
|
+
# for the initial connection to discover the full cluster membership (which may change dynamically)
|
61
|
+
# so this list need not contain the full set of servers (you may want more than one, though, in
|
50
62
|
# case a server is down).
|
51
63
|
config :bootstrap_servers, :validate => :string, :default => "localhost:9092"
|
52
|
-
# Automatically check the CRC32 of the records consumed. This ensures no on-the-wire or on-disk
|
53
|
-
# corruption to the messages occurred. This check adds some overhead, so it may be
|
64
|
+
# Automatically check the CRC32 of the records consumed. This ensures no on-the-wire or on-disk
|
65
|
+
# corruption to the messages occurred. This check adds some overhead, so it may be
|
54
66
|
# disabled in cases seeking extreme performance.
|
55
67
|
config :check_crcs, :validate => :string
|
56
|
-
# The id string to pass to the server when making requests. The purpose of this
|
57
|
-
# is to be able to track the source of requests beyond just ip/port by allowing
|
68
|
+
# The id string to pass to the server when making requests. The purpose of this
|
69
|
+
# is to be able to track the source of requests beyond just ip/port by allowing
|
58
70
|
# a logical application name to be included.
|
59
71
|
config :client_id, :validate => :string, :default => "logstash"
|
60
72
|
# Close idle connections after the number of milliseconds specified by this config.
|
61
73
|
config :connections_max_idle_ms, :validate => :string
|
62
|
-
# Ideally you should have as many threads as the number of partitions for a perfect
|
74
|
+
# Ideally you should have as many threads as the number of partitions for a perfect
|
63
75
|
# balance — more threads than partitions means that some threads will be idle
|
64
76
|
config :consumer_threads, :validate => :number, :default => 1
|
65
77
|
# If true, periodically commit to Kafka the offsets of messages already returned by the consumer.
|
66
|
-
# This committed offset will be used when the process fails as the position from
|
78
|
+
# This committed offset will be used when the process fails as the position from
|
67
79
|
# which the consumption will begin.
|
68
80
|
config :enable_auto_commit, :validate => :string, :default => "true"
|
69
|
-
#
|
70
|
-
#
|
81
|
+
# Whether records from internal topics (such as offsets) should be exposed to the consumer.
|
82
|
+
# If set to true the only way to receive records from an internal topic is subscribing to it.
|
83
|
+
config :exclude_internal_topics, :validate => :string
|
84
|
+
# The maximum amount of time the server will block before answering the fetch request if
|
85
|
+
# there isn't sufficient data to immediately satisfy `fetch_min_bytes`. This
|
71
86
|
# should be less than or equal to the timeout used in `poll_timeout_ms`
|
72
87
|
config :fetch_max_wait_ms, :validate => :string
|
73
|
-
# The minimum amount of data the server should return for a fetch request. If insufficient
|
88
|
+
# The minimum amount of data the server should return for a fetch request. If insufficient
|
74
89
|
# data is available the request will wait for that much data to accumulate
|
75
90
|
# before answering the request.
|
76
91
|
config :fetch_min_bytes, :validate => :string
|
77
|
-
# The identifier of the group this consumer belongs to. Consumer group is a single logical subscriber
|
78
|
-
# that happens to be made up of multiple processors. Messages in a topic will be distributed to all
|
92
|
+
# The identifier of the group this consumer belongs to. Consumer group is a single logical subscriber
|
93
|
+
# that happens to be made up of multiple processors. Messages in a topic will be distributed to all
|
79
94
|
# Logstash instances with the same `group_id`
|
80
95
|
config :group_id, :validate => :string, :default => "logstash"
|
81
96
|
# The expected time between heartbeats to the consumer coordinator. Heartbeats are used to ensure
|
82
97
|
# that the consumer's session stays active and to facilitate rebalancing when new
|
83
|
-
# consumers join or leave the group. The value must be set lower than
|
84
|
-
# `session.timeout.ms`, but typically should be set no higher than 1/3 of that value.
|
98
|
+
# consumers join or leave the group. The value must be set lower than
|
99
|
+
# `session.timeout.ms`, but typically should be set no higher than 1/3 of that value.
|
85
100
|
# It can be adjusted even lower to control the expected time for normal rebalances.
|
86
101
|
config :heartbeat_interval_ms, :validate => :string
|
87
102
|
# Java Class used to deserialize the record's key
|
88
103
|
config :key_deserializer_class, :validate => :string, :default => "org.apache.kafka.common.serialization.StringDeserializer"
|
89
|
-
# The maximum amount of data per-partition the server will return. The maximum total memory used for a
|
90
|
-
# request will be <code>#partitions * max.partition.fetch.bytes</code>. This size must be at least
|
91
|
-
# as large as the maximum message size the server allows or else it is possible for the producer to
|
92
|
-
# send messages larger than the consumer can fetch. If that happens, the consumer can get stuck trying
|
104
|
+
# The maximum amount of data per-partition the server will return. The maximum total memory used for a
|
105
|
+
# request will be <code>#partitions * max.partition.fetch.bytes</code>. This size must be at least
|
106
|
+
# as large as the maximum message size the server allows or else it is possible for the producer to
|
107
|
+
# send messages larger than the consumer can fetch. If that happens, the consumer can get stuck trying
|
93
108
|
# to fetch a large message on a certain partition.
|
94
109
|
config :max_partition_fetch_bytes, :validate => :string
|
95
|
-
# The
|
110
|
+
# The maximum number of records returned in a single call to poll().
|
111
|
+
config :max_poll_records, :validate => :string
|
112
|
+
# The period of time in milliseconds after which we force a refresh of metadata even if
|
113
|
+
# we haven't seen any partition leadership changes to proactively discover any new brokers or partitions
|
114
|
+
config :metadata_max_age_ms, :validate => :string
|
115
|
+
# The class name of the partition assignment strategy that the client will use to distribute
|
96
116
|
# partition ownership amongst consumer instances
|
97
117
|
config :partition_assignment_strategy, :validate => :string
|
98
118
|
# The size of the TCP receive buffer (SO_RCVBUF) to use when reading data.
|
99
119
|
config :receive_buffer_bytes, :validate => :string
|
100
|
-
# The amount of time to wait before attempting to reconnect to a given host.
|
101
|
-
# This avoids repeatedly connecting to a host in a tight loop.
|
120
|
+
# The amount of time to wait before attempting to reconnect to a given host.
|
121
|
+
# This avoids repeatedly connecting to a host in a tight loop.
|
102
122
|
# This backoff applies to all requests sent by the consumer to the broker.
|
103
123
|
config :reconnect_backoff_ms, :validate => :string
|
104
|
-
# The configuration controls the maximum amount of time the client will wait
|
105
|
-
# for the response of a request. If the response is not received before the timeout
|
106
|
-
# elapses the client will resend the request if necessary or fail the request if
|
124
|
+
# The configuration controls the maximum amount of time the client will wait
|
125
|
+
# for the response of a request. If the response is not received before the timeout
|
126
|
+
# elapses the client will resend the request if necessary or fail the request if
|
107
127
|
# retries are exhausted.
|
108
128
|
config :request_timeout_ms, :validate => :string
|
109
|
-
# The amount of time to wait before attempting to retry a failed fetch request
|
129
|
+
# The amount of time to wait before attempting to retry a failed fetch request
|
110
130
|
# to a given topic partition. This avoids repeated fetching-and-failing in a tight loop.
|
111
131
|
config :retry_backoff_ms, :validate => :string
|
112
|
-
# The
|
132
|
+
# The size of the TCP send buffer (SO_SNDBUF) to use when sending data
|
133
|
+
config :send_buffer_bytes, :validate => :string
|
134
|
+
# The timeout after which, if the `poll_timeout_ms` is not invoked, the consumer is marked dead
|
113
135
|
# and a rebalance operation is triggered for the group identified by `group_id`
|
114
|
-
config :session_timeout_ms, :validate => :string
|
136
|
+
config :session_timeout_ms, :validate => :string
|
115
137
|
# Java Class used to deserialize the record's value
|
116
138
|
config :value_deserializer_class, :validate => :string, :default => "org.apache.kafka.common.serialization.StringDeserializer"
|
117
|
-
# A list of topics to subscribe to
|
118
|
-
config :topics, :validate => :array, :
|
119
|
-
# A topic regex pattern to subscribe to.
|
120
|
-
# The topics configuration will be ignored when using this configuration.
|
121
|
-
config :topics_pattern, :validate => :string
|
139
|
+
# A list of topics to subscribe to.
|
140
|
+
config :topics, :validate => :array, :required => true
|
122
141
|
# Time kafka consumer will wait to receive new messages from topics
|
123
|
-
config :poll_timeout_ms, :validate => :number
|
124
|
-
# Enable SSL/TLS secured communication to Kafka broker.
|
125
|
-
# is only available with a broker running v0.9 of Kafka.
|
142
|
+
config :poll_timeout_ms, :validate => :number
|
143
|
+
# Enable SSL/TLS secured communication to Kafka broker.
|
126
144
|
config :ssl, :validate => :boolean, :default => false
|
127
145
|
# The JKS truststore path to validate the Kafka broker's certificate.
|
128
146
|
config :ssl_truststore_location, :validate => :path
|
@@ -132,22 +150,11 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
132
150
|
config :ssl_keystore_location, :validate => :path
|
133
151
|
# If client authentication is required, this setting stores the keystore password
|
134
152
|
config :ssl_keystore_password, :validate => :password
|
135
|
-
# Option to add Kafka metadata like topic, message size to the event.
|
136
|
-
# This will add a field named `kafka` to the logstash event containing the following attributes:
|
137
|
-
# `topic`: The topic this message is associated with
|
138
|
-
# `consumer_group`: The consumer group used to read in this event
|
139
|
-
# `partition`: The partition this message is associated with
|
140
|
-
# `offset`: The offset from the partition this message is associated with
|
141
|
-
# `key`: A ByteBuffer containing the message key
|
142
|
-
config :decorate_events, :validate => :boolean, :default => false
|
143
153
|
|
144
|
-
|
154
|
+
|
145
155
|
public
|
146
156
|
def register
|
147
|
-
|
148
|
-
if defined?(LogStash::Logger) && LogStash::Logger.respond_to?(:setup_log4j)
|
149
|
-
LogStash::Logger.setup_log4j(@logger)
|
150
|
-
end
|
157
|
+
LogStash::Logger.setup_log4j(@logger)
|
151
158
|
@runner_threads = []
|
152
159
|
end # def register
|
153
160
|
|
@@ -167,25 +174,12 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
167
174
|
def thread_runner(logstash_queue, consumer)
|
168
175
|
Thread.new do
|
169
176
|
begin
|
170
|
-
|
171
|
-
nooplistener = org.apache.kafka.clients.consumer.internals.NoOpConsumerRebalanceListener.new
|
172
|
-
pattern = java.util.regex.Pattern.compile(@topics_pattern)
|
173
|
-
consumer.subscribe(pattern, nooplistener)
|
174
|
-
else
|
175
|
-
consumer.subscribe(topics);
|
176
|
-
end
|
177
|
+
consumer.subscribe(topics);
|
177
178
|
while !stop?
|
178
179
|
records = consumer.poll(poll_timeout_ms);
|
179
180
|
for record in records do
|
180
181
|
@codec.decode(record.value.to_s) do |event|
|
181
182
|
decorate(event)
|
182
|
-
if @decorate_events
|
183
|
-
event.set("[kafka][topic]", record.topic)
|
184
|
-
event.set("[kafka][consumer_group]", @group_id)
|
185
|
-
event.set("[kafka][partition]", record.partition)
|
186
|
-
event.set("[kafka][offset]", record.offset)
|
187
|
-
event.set("[kafka][key]", record.key)
|
188
|
-
end
|
189
183
|
logstash_queue << event
|
190
184
|
end
|
191
185
|
end
|
@@ -211,17 +205,21 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
211
205
|
props.put(kafka::CLIENT_ID_CONFIG, client_id)
|
212
206
|
props.put(kafka::CONNECTIONS_MAX_IDLE_MS_CONFIG, connections_max_idle_ms) unless connections_max_idle_ms.nil?
|
213
207
|
props.put(kafka::ENABLE_AUTO_COMMIT_CONFIG, enable_auto_commit)
|
208
|
+
props.put(kafka::EXCLUDE_INTERNAL_TOPICS_CONFIG, exclude_internal_topics) unless exclude_internal_topics.nil?
|
214
209
|
props.put(kafka::FETCH_MAX_WAIT_MS_CONFIG, fetch_max_wait_ms) unless fetch_max_wait_ms.nil?
|
215
210
|
props.put(kafka::FETCH_MIN_BYTES_CONFIG, fetch_min_bytes) unless fetch_min_bytes.nil?
|
216
211
|
props.put(kafka::GROUP_ID_CONFIG, group_id)
|
217
212
|
props.put(kafka::HEARTBEAT_INTERVAL_MS_CONFIG, heartbeat_interval_ms) unless heartbeat_interval_ms.nil?
|
218
213
|
props.put(kafka::KEY_DESERIALIZER_CLASS_CONFIG, key_deserializer_class)
|
219
214
|
props.put(kafka::MAX_PARTITION_FETCH_BYTES_CONFIG, max_partition_fetch_bytes) unless max_partition_fetch_bytes.nil?
|
215
|
+
props.put(kafka::MAX_POLL_RECORDS_CONFIG, max_poll_records) unless max_poll_records.nil?
|
216
|
+
props.put(kafka::METADATA_MAX_AGE_MS_CONFIG, metadata_max_age_ms) unless metadata_max_age_ms.nil?
|
220
217
|
props.put(kafka::PARTITION_ASSIGNMENT_STRATEGY_CONFIG, partition_assignment_strategy) unless partition_assignment_strategy.nil?
|
221
218
|
props.put(kafka::RECEIVE_BUFFER_CONFIG, receive_buffer_bytes) unless receive_buffer_bytes.nil?
|
222
219
|
props.put(kafka::RECONNECT_BACKOFF_MS_CONFIG, reconnect_backoff_ms) unless reconnect_backoff_ms.nil?
|
223
220
|
props.put(kafka::REQUEST_TIMEOUT_MS_CONFIG, request_timeout_ms) unless request_timeout_ms.nil?
|
224
221
|
props.put(kafka::RETRY_BACKOFF_MS_CONFIG, retry_backoff_ms) unless retry_backoff_ms.nil?
|
222
|
+
props.put(kafka::SEND_BUFFER_CONFIG, send_buffer_bytes) unless send_buffer_bytes.nil?
|
225
223
|
props.put(kafka::SESSION_TIMEOUT_MS_CONFIG, session_timeout_ms) unless session_timeout_ms.nil?
|
226
224
|
props.put(kafka::VALUE_DESERIALIZER_CLASS_CONFIG, value_deserializer_class)
|
227
225
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-kafka'
|
4
|
-
s.version = '
|
4
|
+
s.version = '5.0.1'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = 'This input will read events from a Kafka topic. It uses the high level consumer API provided by Kafka to read messages from the broker'
|
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"
|
@@ -19,8 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
# Special flag to let us know this is actually a logstash plugin
|
20
20
|
s.metadata = { 'logstash_plugin' => 'true', 'group' => 'input'}
|
21
21
|
|
22
|
-
s.requirements << "jar 'org.apache.kafka:kafka-clients', '0.
|
23
|
-
s.requirements << "jar 'org.slf4j:slf4j-log4j12', '1.7.
|
22
|
+
s.requirements << "jar 'org.apache.kafka:kafka-clients', '0.10.0.0'"
|
23
|
+
s.requirements << "jar 'org.slf4j:slf4j-log4j12', '1.7.21'"
|
24
24
|
|
25
25
|
s.add_development_dependency 'jar-dependencies', '~> 0.3.2'
|
26
26
|
|
@@ -31,5 +31,6 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.add_runtime_dependency 'stud', '>= 0.0.22', '< 0.1.0'
|
32
32
|
|
33
33
|
s.add_development_dependency 'logstash-devutils'
|
34
|
+
s.add_development_dependency 'rspec-wait'
|
34
35
|
end
|
35
36
|
|
@@ -4,97 +4,47 @@ require "logstash/inputs/kafka"
|
|
4
4
|
require "digest"
|
5
5
|
require "rspec/wait"
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
let(:
|
11
|
-
|
12
|
-
let(:
|
13
|
-
let(:plain_config) { { 'topics' => ['logstash_topic_plain'], 'codec' => 'plain', 'group_id' => group_id_1, 'auto_offset_reset' => 'earliest'} }
|
14
|
-
let(:snappy_config) { { 'topics' => ['logstash_topic_snappy'], 'codec' => 'plain', 'group_id' => group_id_1, 'auto_offset_reset' => 'earliest'} }
|
15
|
-
let(:lz4_config) { { 'topics' => ['logstash_topic_lz4'], 'codec' => 'plain', 'group_id' => group_id_1, 'auto_offset_reset' => 'earliest'} }
|
16
|
-
let(:pattern_config) { { 'topics_pattern' => 'logstash_topic_.*', 'group_id' => group_id_2, 'codec' => 'plain', 'auto_offset_reset' => 'earliest'} }
|
17
|
-
let(:decorate_config) { { 'topics' => ['logstash_topic_plain'], 'codec' => 'plain', 'group_id' => group_id_3, 'auto_offset_reset' => 'earliest', 'decorate_events' => true} }
|
18
|
-
let(:timeout_seconds) { 120 }
|
7
|
+
describe "input/kafka", :integration => true do
|
8
|
+
let(:partition3_config) { { 'topics' => ['topic3'], 'codec' => 'plain', 'auto_offset_reset' => 'earliest'} }
|
9
|
+
let(:snappy_config) { { 'topics' => ['snappy_topic'], 'codec' => 'plain', 'auto_offset_reset' => 'earliest'} }
|
10
|
+
let(:lz4_config) { { 'topics' => ['lz4_topic'], 'codec' => 'plain', 'auto_offset_reset' => 'earliest'} }
|
11
|
+
|
12
|
+
let(:timeout_seconds) { 3600 }
|
19
13
|
let(:num_events) { 103 }
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
kafka_input.run(queue)
|
26
|
-
end
|
14
|
+
|
15
|
+
def thread_it(kafka_input, queue)
|
16
|
+
Thread.new do
|
17
|
+
begin
|
18
|
+
kafka_input.run(queue)
|
27
19
|
end
|
28
20
|
end
|
29
|
-
|
30
|
-
it "should consume all messages from plain 3-partition topic" do
|
31
|
-
kafka_input = LogStash::Inputs::Kafka.new(plain_config)
|
32
|
-
queue = Array.new
|
33
|
-
t = thread_it(kafka_input, queue)
|
34
|
-
t.run
|
35
|
-
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
36
|
-
expect(queue.length).to eq(num_events)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should consume all messages from snappy 3-partition topic" do
|
40
|
-
kafka_input = LogStash::Inputs::Kafka.new(snappy_config)
|
41
|
-
queue = Array.new
|
42
|
-
t = thread_it(kafka_input, queue)
|
43
|
-
t.run
|
44
|
-
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
45
|
-
expect(queue.length).to eq(num_events)
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should consume all messages from lz4 3-partition topic" do
|
49
|
-
kafka_input = LogStash::Inputs::Kafka.new(lz4_config)
|
50
|
-
queue = Array.new
|
51
|
-
t = thread_it(kafka_input, queue)
|
52
|
-
t.run
|
53
|
-
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
54
|
-
expect(queue.length).to eq(num_events)
|
55
|
-
end
|
56
|
-
|
57
21
|
end
|
58
|
-
|
59
|
-
describe "#kafka-topics-pattern" do
|
60
22
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
23
|
+
it "should consume all messages from 3-partition topic" do
|
24
|
+
kafka_input = LogStash::Inputs::Kafka.new(partition3_config)
|
25
|
+
queue = Array.new
|
26
|
+
t = thread_it(kafka_input, queue)
|
27
|
+
t.run
|
28
|
+
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
29
|
+
expect(queue.length).to eq(num_events)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should consume all messages from snappy 3-partition topic" do
|
33
|
+
kafka_input = LogStash::Inputs::Kafka.new(snappy_config)
|
34
|
+
queue = Array.new
|
35
|
+
t = thread_it(kafka_input, queue)
|
36
|
+
t.run
|
37
|
+
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
38
|
+
expect(queue.length).to eq(num_events)
|
77
39
|
end
|
78
40
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should show the right topic and group name in decorated kafka section" do
|
89
|
-
kafka_input = LogStash::Inputs::Kafka.new(decorate_config)
|
90
|
-
queue = Queue.new
|
91
|
-
t = thread_it(kafka_input, queue)
|
92
|
-
t.run
|
93
|
-
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
94
|
-
expect(queue.length).to eq(num_events)
|
95
|
-
event = queue.shift
|
96
|
-
expect(event.get("kafka")["topic"]).to eq("logstash_topic_plain")
|
97
|
-
expect(event.get("kafka")["consumer_group"]).to eq(group_id_3)
|
98
|
-
end
|
41
|
+
it "should consume all messages from lz4 3-partition topic" do
|
42
|
+
kafka_input = LogStash::Inputs::Kafka.new(lz4_config)
|
43
|
+
queue = Array.new
|
44
|
+
t = thread_it(kafka_input, queue)
|
45
|
+
t.run
|
46
|
+
wait(timeout_seconds).for { queue.length }.to eq(num_events)
|
47
|
+
expect(queue.length).to eq(num_events)
|
99
48
|
end
|
49
|
+
|
100
50
|
end
|
@@ -16,7 +16,7 @@ class MockConsumer
|
|
16
16
|
raise org.apache.kafka.common.errors.WakeupException.new
|
17
17
|
else
|
18
18
|
10.times.map do
|
19
|
-
org.apache.kafka.clients.consumer.ConsumerRecord.new("
|
19
|
+
org.apache.kafka.clients.consumer.ConsumerRecord.new("test", 0, 0, "key", "value")
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -30,7 +30,7 @@ class MockConsumer
|
|
30
30
|
end
|
31
31
|
|
32
32
|
describe LogStash::Inputs::Kafka do
|
33
|
-
let(:config) { { 'topics' => ['
|
33
|
+
let(:config) { { 'topics' => ['test'], 'consumer_threads' => 4 } }
|
34
34
|
subject { LogStash::Inputs::Kafka.new(config) }
|
35
35
|
|
36
36
|
it "should register" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-kafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +106,20 @@ dependencies:
|
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
requirement: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
name: rspec-wait
|
116
|
+
prerelease: false
|
117
|
+
type: :development
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
109
123
|
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
|
110
124
|
email: info@elastic.co
|
111
125
|
executables: []
|
@@ -119,23 +133,11 @@ files:
|
|
119
133
|
- LICENSE
|
120
134
|
- NOTICE.TXT
|
121
135
|
- README.md
|
122
|
-
- lib/log4j/log4j/1.2.17/log4j-1.2.17.jar
|
123
136
|
- lib/logstash-input-kafka_jars.rb
|
124
137
|
- lib/logstash/inputs/kafka.rb
|
125
|
-
- lib/net/jpountz/lz4/lz4/1.2.0/lz4-1.2.0.jar
|
126
|
-
- lib/org/apache/kafka/kafka-clients/0.9.0.1/kafka-clients-0.9.0.1.jar
|
127
|
-
- lib/org/slf4j/slf4j-api/1.7.6/slf4j-api-1.7.6.jar
|
128
|
-
- lib/org/slf4j/slf4j-log4j12/1.7.13/slf4j-log4j12-1.7.13.jar
|
129
|
-
- lib/org/xerial/snappy/snappy-java/1.1.1.7/snappy-java-1.1.1.7.jar
|
130
138
|
- logstash-input-kafka.gemspec
|
131
139
|
- spec/integration/inputs/kafka_spec.rb
|
132
140
|
- spec/unit/inputs/kafka_spec.rb
|
133
|
-
- vendor/jar-dependencies/runtime-jars/kafka-clients-0.9.0.1.jar
|
134
|
-
- vendor/jar-dependencies/runtime-jars/log4j-1.2.17.jar
|
135
|
-
- vendor/jar-dependencies/runtime-jars/lz4-1.2.0.jar
|
136
|
-
- vendor/jar-dependencies/runtime-jars/slf4j-api-1.7.6.jar
|
137
|
-
- vendor/jar-dependencies/runtime-jars/slf4j-log4j12-1.7.13.jar
|
138
|
-
- vendor/jar-dependencies/runtime-jars/snappy-java-1.1.1.7.jar
|
139
141
|
homepage: http://www.elastic.co/guide/en/logstash/current/index.html
|
140
142
|
licenses:
|
141
143
|
- Apache License (2.0)
|
@@ -157,10 +159,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
159
|
- !ruby/object:Gem::Version
|
158
160
|
version: '0'
|
159
161
|
requirements:
|
160
|
-
- jar 'org.apache.kafka:kafka-clients', '0.
|
161
|
-
- jar 'org.slf4j:slf4j-log4j12', '1.7.
|
162
|
+
- jar 'org.apache.kafka:kafka-clients', '0.10.0.0'
|
163
|
+
- jar 'org.slf4j:slf4j-log4j12', '1.7.21'
|
162
164
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.6.3
|
164
166
|
signing_key:
|
165
167
|
specification_version: 4
|
166
168
|
summary: This input will read events from a Kafka topic. It uses the high level consumer API provided by Kafka to read messages from the broker
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|