logstash-input-kafka 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTORS +15 -0
- data/DEVELOPER.md +40 -0
- data/LICENSE +1 -1
- data/README.md +95 -40
- data/lib/logstash/inputs/kafka.rb +8 -2
- data/logstash-input-kafka.gemspec +2 -2
- data/spec/inputs/kafka_spec.rb +13 -9
- metadata +29 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7125e1ff6df197c33c40a2eee55bae2d46ded688
|
4
|
+
data.tar.gz: af31b79628824cb5b40c70c5bbfce49f4ed7b552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53c45f8a5fb0f9aa0cdc17ab14b76bd404967e50cbd46f35d295469a19a3b9e4d09f2cb7e394fb52387f023f8a7025b3be26b961291dd1ac4d85accefc37fee0
|
7
|
+
data.tar.gz: 5837abb53af1460d13bddf741c400ffed437ce302382b38b3f098901fab394c4766f81d6ca0a5c0bc7f6ceb2f987427835a4aa2795823f367c9ba72414c3b2df
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,15 @@
|
|
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
|
+
* Joseph Lawson (joekiller)
|
6
|
+
* Pere Urbón (purbon)
|
7
|
+
* Pier-Hugues Pellerin (ph)
|
8
|
+
* Richard Pijnenburg (electrical)
|
9
|
+
* Suyog Rao (suyograo)
|
10
|
+
* Tal Levy (talevy)
|
11
|
+
|
12
|
+
Note: If you've sent us patches, bug reports, or otherwise contributed to
|
13
|
+
Logstash, and you aren't on the list above and want to be, please let us know
|
14
|
+
and we'll make sure you're here. Contributions from folks like you are what make
|
15
|
+
open source awesome.
|
data/DEVELOPER.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
logstash-input-kafka
|
2
|
+
====================
|
3
|
+
|
4
|
+
Apache Kafka input for Logstash. This input will consume messages from a Kafka topic using the high level consumer API exposed by Kafka.
|
5
|
+
|
6
|
+
For more information about Kafka, refer to this [documentation](http://kafka.apache.org/documentation.html)
|
7
|
+
|
8
|
+
Information about high level consumer API can be found [here](http://kafka.apache.org/documentation.html#highlevelconsumerapi)
|
9
|
+
|
10
|
+
Logstash Configuration
|
11
|
+
====================
|
12
|
+
|
13
|
+
See http://kafka.apache.org/documentation.html#consumerconfigs for details about the Kafka consumer options.
|
14
|
+
|
15
|
+
input {
|
16
|
+
kafka {
|
17
|
+
topic_id => ... # string (required), The topic to consume messages from
|
18
|
+
zk_connect => ... # string (optional), default: "localhost:2181", Specifies the ZooKeeper connection string in the form hostname:port
|
19
|
+
group_id => ... # string (optional), default: "logstash", A string that uniquely identifies the group of consumer processes
|
20
|
+
reset_beginning => ... # boolean (optional), default: false, Specify whether to jump to beginning of the queue when there is no initial offset in ZK
|
21
|
+
consumer_threads => ... # number (optional), default: 1, Number of threads to read from the partitions
|
22
|
+
queue_size => ... # number (optional), default: 20, Internal Logstash queue size used to hold events in memory
|
23
|
+
rebalance_max_retries => ... # number (optional), default: 4
|
24
|
+
rebalance_backoff_ms => ... # number (optional), default: 2000
|
25
|
+
consumer_timeout_ms => ... # number (optional), default: -1
|
26
|
+
consumer_restart_on_error => ... # boolean (optional), default: true
|
27
|
+
consumer_restart_sleep_ms => ... # number (optional), default: 0
|
28
|
+
decorate_events => ... # boolean (optional), default: false, Option to add Kafka metadata like topic, message size to the event
|
29
|
+
consumer_id => ... # string (optional) default: nil
|
30
|
+
fetch_message_max_bytes => ... # number (optional) default: 1048576
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
The default codec is json
|
35
|
+
|
36
|
+
Dependencies
|
37
|
+
====================
|
38
|
+
|
39
|
+
* Apache Kafka version 0.8.1.1
|
40
|
+
* jruby-kafka library
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012-
|
1
|
+
Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
|
2
2
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
you may not use this file except in compliance with the License.
|
data/README.md
CHANGED
@@ -1,40 +1,95 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
1
|
+
# Logstash Plugin
|
2
|
+
|
3
|
+
This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
## Documentation
|
8
|
+
|
9
|
+
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.elasticsearch.org/guide/en/logstash/current/).
|
10
|
+
|
11
|
+
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
|
12
|
+
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
|
13
|
+
|
14
|
+
## Need Help?
|
15
|
+
|
16
|
+
Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
|
17
|
+
|
18
|
+
## Developing
|
19
|
+
|
20
|
+
### 1. Plugin Developement and Testing
|
21
|
+
|
22
|
+
#### Code
|
23
|
+
- To get started, you'll need JRuby with the Bundler gem installed.
|
24
|
+
|
25
|
+
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization.
|
26
|
+
|
27
|
+
- Install dependencies
|
28
|
+
```sh
|
29
|
+
bundle install
|
30
|
+
```
|
31
|
+
|
32
|
+
#### Test
|
33
|
+
|
34
|
+
```sh
|
35
|
+
bundle exec rspec
|
36
|
+
```
|
37
|
+
|
38
|
+
The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
|
39
|
+
```ruby
|
40
|
+
gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
|
41
|
+
```
|
42
|
+
To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
|
43
|
+
```ruby
|
44
|
+
gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
|
45
|
+
```
|
46
|
+
```ruby
|
47
|
+
gem "logstash", :path => "/your/local/logstash"
|
48
|
+
```
|
49
|
+
|
50
|
+
Then update your dependencies and run your tests:
|
51
|
+
|
52
|
+
```sh
|
53
|
+
bundle install
|
54
|
+
bundle exec rspec
|
55
|
+
```
|
56
|
+
|
57
|
+
### 2. Running your unpublished Plugin in Logstash
|
58
|
+
|
59
|
+
#### 2.1 Run in a local Logstash clone
|
60
|
+
|
61
|
+
- Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
|
62
|
+
```ruby
|
63
|
+
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
64
|
+
```
|
65
|
+
- Update Logstash dependencies
|
66
|
+
```sh
|
67
|
+
rake vendor:gems
|
68
|
+
```
|
69
|
+
- Run Logstash with your plugin
|
70
|
+
```sh
|
71
|
+
bin/logstash -e 'filter {awesome {}}'
|
72
|
+
```
|
73
|
+
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
|
74
|
+
|
75
|
+
#### 2.2 Run in an installed Logstash
|
76
|
+
|
77
|
+
- Build your plugin gem
|
78
|
+
```sh
|
79
|
+
gem build logstash-filter-awesome.gemspec
|
80
|
+
```
|
81
|
+
- Install the plugin from the Logstash home
|
82
|
+
```sh
|
83
|
+
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
|
84
|
+
```
|
85
|
+
- Start Logstash and proceed to test the plugin
|
86
|
+
|
87
|
+
## Contributing
|
88
|
+
|
89
|
+
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
|
90
|
+
|
91
|
+
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.
|
92
|
+
|
93
|
+
It is more important to me that you are able to contribute.
|
94
|
+
|
95
|
+
For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
|
@@ -18,7 +18,6 @@ require 'logstash-input-kafka_jars'
|
|
18
18
|
#
|
19
19
|
class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
20
20
|
config_name 'kafka'
|
21
|
-
milestone 1
|
22
21
|
|
23
22
|
default :codec, 'json'
|
24
23
|
|
@@ -81,7 +80,9 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
81
80
|
|
82
81
|
public
|
83
82
|
def register
|
83
|
+
LogStash::Logger.setup_log4j(@logger)
|
84
84
|
require 'jruby-kafka'
|
85
|
+
|
85
86
|
options = {
|
86
87
|
:zk_connect => @zk_connect,
|
87
88
|
:group_id => @group_id,
|
@@ -98,7 +99,7 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
98
99
|
options[:reset_beginning] = 'from-beginning'
|
99
100
|
end # if :reset_beginning
|
100
101
|
@kafka_client_queue = SizedQueue.new(@queue_size)
|
101
|
-
@consumer_group =
|
102
|
+
@consumer_group = create_consumer_group(options)
|
102
103
|
@logger.info('Registering kafka', :group_id => @group_id, :topic_id => @topic_id, :zk_connect => @zk_connect)
|
103
104
|
end # def register
|
104
105
|
|
@@ -134,6 +135,11 @@ class LogStash::Inputs::Kafka < LogStash::Inputs::Base
|
|
134
135
|
finished
|
135
136
|
end # def run
|
136
137
|
|
138
|
+
private
|
139
|
+
def create_consumer_group(options)
|
140
|
+
Kafka::Group.new(options)
|
141
|
+
end
|
142
|
+
|
137
143
|
private
|
138
144
|
def queue_event(msg, output_queue)
|
139
145
|
begin
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-kafka'
|
4
|
-
s.version = '0.1.
|
4
|
+
s.version = '0.1.7'
|
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/plugin install gemname. This gem is not a stand-alone program"
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
# Jar dependencies
|
23
23
|
s.requirements << "jar 'org.apache.kafka:kafka_2.9.2', '0.8.1.1'"
|
24
|
-
s.requirements << "jar '
|
24
|
+
s.requirements << "jar 'org.slf4j:slf4j-log4j12', '1.7.10'"
|
25
25
|
|
26
26
|
# Gem dependencies
|
27
27
|
s.add_runtime_dependency 'logstash', '>= 1.4.0', '< 2.0.0'
|
data/spec/inputs/kafka_spec.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "logstash/devutils/rspec/spec_helper"
|
3
3
|
require "logstash/inputs/kafka"
|
4
|
+
require 'jruby-kafka'
|
4
5
|
|
5
6
|
class LogStash::Inputs::TestKafka < LogStash::Inputs::Kafka
|
6
|
-
milestone 1
|
7
7
|
private
|
8
8
|
def queue_event(msg, output_queue)
|
9
9
|
super(msg, output_queue)
|
@@ -13,6 +13,12 @@ class LogStash::Inputs::TestKafka < LogStash::Inputs::Kafka
|
|
13
13
|
end
|
14
14
|
|
15
15
|
|
16
|
+
class TestKafkaGroup < Kafka::Group
|
17
|
+
def run(a_num_threads, a_queue)
|
18
|
+
a_queue << 'Kafka message'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
16
22
|
describe 'inputs/kafka' do
|
17
23
|
let (:kafka_config) {{'topic_id' => 'test'}}
|
18
24
|
let (:decorated_kafka_config) {{'topic_id' => 'test', 'decorate_events' => true}}
|
@@ -32,11 +38,10 @@ describe 'inputs/kafka' do
|
|
32
38
|
|
33
39
|
it 'should retrieve event from kafka' do
|
34
40
|
kafka = LogStash::Inputs::TestKafka.new(kafka_config)
|
35
|
-
kafka.
|
36
|
-
|
37
|
-
expect_any_instance_of(Kafka::Group).to receive(:run) do |a_num_threads, a_queue|
|
38
|
-
a_queue << 'Kafka message'
|
41
|
+
expect(kafka).to receive(:create_consumer_group) do |options|
|
42
|
+
TestKafkaGroup.new(options)
|
39
43
|
end
|
44
|
+
kafka.register
|
40
45
|
|
41
46
|
logstash_queue = Queue.new
|
42
47
|
kafka.run logstash_queue
|
@@ -48,11 +53,10 @@ describe 'inputs/kafka' do
|
|
48
53
|
|
49
54
|
it 'should retrieve a decorated event from kafka' do
|
50
55
|
kafka = LogStash::Inputs::TestKafka.new(decorated_kafka_config)
|
51
|
-
kafka.
|
52
|
-
|
53
|
-
expect_any_instance_of(Kafka::Group).to receive(:run) do |a_num_threads, a_queue|
|
54
|
-
a_queue << 'Kafka message'
|
56
|
+
expect(kafka).to receive(:create_consumer_group) do |options|
|
57
|
+
TestKafkaGroup.new(options)
|
55
58
|
end
|
59
|
+
kafka.register
|
56
60
|
|
57
61
|
logstash_queue = Queue.new
|
58
62
|
kafka.run logstash_queue
|
metadata
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-kafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elasticsearch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - '>='
|
18
17
|
- !ruby/object:Gem::Version
|
@@ -20,7 +19,10 @@ dependencies:
|
|
20
19
|
- - <
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: 2.0.0
|
23
|
-
|
22
|
+
name: logstash
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
26
|
requirements:
|
25
27
|
- - '>='
|
26
28
|
- !ruby/object:Gem::Version
|
@@ -28,78 +30,76 @@ dependencies:
|
|
28
30
|
- - <
|
29
31
|
- !ruby/object:Gem::Version
|
30
32
|
version: 2.0.0
|
31
|
-
prerelease: false
|
32
|
-
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-codec-json
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - '>='
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
34
|
requirement: !ruby/object:Gem::Requirement
|
41
35
|
requirements:
|
42
36
|
- - '>='
|
43
37
|
- !ruby/object:Gem::Version
|
44
38
|
version: '0'
|
39
|
+
name: logstash-codec-json
|
45
40
|
prerelease: false
|
46
41
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: logstash-codec-plain
|
49
42
|
version_requirements: !ruby/object:Gem::Requirement
|
50
43
|
requirements:
|
51
44
|
- - '>='
|
52
45
|
- !ruby/object:Gem::Version
|
53
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
55
49
|
requirements:
|
56
50
|
- - '>='
|
57
51
|
- !ruby/object:Gem::Version
|
58
52
|
version: '0'
|
53
|
+
name: logstash-codec-plain
|
59
54
|
prerelease: false
|
60
55
|
type: :runtime
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: jar-dependencies
|
63
56
|
version_requirements: !ruby/object:Gem::Requirement
|
64
57
|
requirements:
|
65
|
-
- -
|
58
|
+
- - '>='
|
66
59
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
68
62
|
requirement: !ruby/object:Gem::Requirement
|
69
63
|
requirements:
|
70
64
|
- - ~>
|
71
65
|
- !ruby/object:Gem::Version
|
72
66
|
version: 0.1.0
|
67
|
+
name: jar-dependencies
|
73
68
|
prerelease: false
|
74
69
|
type: :runtime
|
75
|
-
- !ruby/object:Gem::Dependency
|
76
|
-
name: jruby-kafka
|
77
70
|
version_requirements: !ruby/object:Gem::Requirement
|
78
71
|
requirements:
|
79
|
-
- -
|
72
|
+
- - ~>
|
80
73
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
74
|
+
version: 0.1.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
82
76
|
requirement: !ruby/object:Gem::Requirement
|
83
77
|
requirements:
|
84
78
|
- - '>='
|
85
79
|
- !ruby/object:Gem::Version
|
86
80
|
version: 0.2.1
|
81
|
+
name: jruby-kafka
|
87
82
|
prerelease: false
|
88
83
|
type: :runtime
|
89
|
-
- !ruby/object:Gem::Dependency
|
90
|
-
name: logstash-devutils
|
91
84
|
version_requirements: !ruby/object:Gem::Requirement
|
92
85
|
requirements:
|
93
86
|
- - '>='
|
94
87
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
88
|
+
version: 0.2.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
96
90
|
requirement: !ruby/object:Gem::Requirement
|
97
91
|
requirements:
|
98
92
|
- - '>='
|
99
93
|
- !ruby/object:Gem::Version
|
100
94
|
version: '0'
|
95
|
+
name: logstash-devutils
|
101
96
|
prerelease: false
|
102
97
|
type: :development
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
103
|
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
|
104
104
|
email: info@elasticsearch.com
|
105
105
|
executables: []
|
@@ -107,6 +107,8 @@ extensions: []
|
|
107
107
|
extra_rdoc_files: []
|
108
108
|
files:
|
109
109
|
- .gitignore
|
110
|
+
- CONTRIBUTORS
|
111
|
+
- DEVELOPER.md
|
110
112
|
- Gemfile
|
111
113
|
- LICENSE
|
112
114
|
- README.md
|
@@ -136,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
138
|
version: '0'
|
137
139
|
requirements:
|
138
140
|
- jar 'org.apache.kafka:kafka_2.9.2', '0.8.1.1'
|
139
|
-
- jar '
|
141
|
+
- jar 'org.slf4j:slf4j-log4j12', '1.7.10'
|
140
142
|
rubyforge_project:
|
141
143
|
rubygems_version: 2.1.9
|
142
144
|
signing_key:
|