logstash-input-kinesis 1.1.0-java → 1.2.0-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 +4 -4
- data/Rakefile +7 -0
- data/lib/logstash/inputs/kinesis.rb +51 -52
- data/lib/logstash/inputs/kinesis/version.rb +1 -1
- data/lib/logstash/inputs/kinesis/worker.rb +56 -0
- metadata +44 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f080dee0175be6a16a2a124590f0e92a20ccf45e
|
4
|
+
data.tar.gz: 7e3bf28cf181418701f9ac5041512c1b7c2000a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79c16f7b23a7607c852aa6570f8ab807812cf85087d0aab152ce3fc73b6a2e0f365e606670e8c22393aa173c56df26c7c7ea05afc2b1d758049494dfc64d49a
|
7
|
+
data.tar.gz: 562275486d2548074591e98063f5e54ba5f8a39fd0c45a3f2011aec6e009465afd05bc2bf81fcc7eccc4c400ccebd2e883ae6ca549167dd7b798421639a12b6b
|
data/Rakefile
CHANGED
@@ -4,15 +4,34 @@ require "logstash/errors"
|
|
4
4
|
require "logstash/environment"
|
5
5
|
require "logstash/namespace"
|
6
6
|
|
7
|
-
require "logstash/inputs/kinesis/version"
|
8
7
|
require 'logstash-input-kinesis_jars'
|
8
|
+
require "logstash/inputs/kinesis/version"
|
9
9
|
|
10
|
+
# Receive events through an AWS Kinesis stream.
|
11
|
+
#
|
12
|
+
# This input plugin uses the Java Kinesis Client Library underneath, so the
|
13
|
+
# documentation at https://github.com/awslabs/amazon-kinesis-client will be
|
14
|
+
# useful.
|
15
|
+
#
|
16
|
+
# AWS credentials can be specified either through environment variables, or an
|
17
|
+
# IAM instance role. The library uses a DynamoDB table for worker coordination,
|
18
|
+
# so you'll need to grant access to that as well as to the Kinesis stream. The
|
19
|
+
# DynamoDB table has the same name as the `application_name` configuration
|
20
|
+
# option, which defaults to "logstash".
|
21
|
+
#
|
22
|
+
# The library can optionally also send worker statistics to CloudWatch.
|
10
23
|
class LogStash::Inputs::Kinesis < LogStash::Inputs::Base
|
11
24
|
KCL = com.amazonaws.services.kinesis.clientlibrary.lib.worker
|
25
|
+
require "logstash/inputs/kinesis/worker"
|
12
26
|
|
13
27
|
config_name 'kinesis'
|
14
28
|
milestone 1
|
15
29
|
|
30
|
+
attr_reader(
|
31
|
+
:kcl_config,
|
32
|
+
:kcl_worker,
|
33
|
+
)
|
34
|
+
|
16
35
|
# The application name used for the dynamodb coordination table. Must be
|
17
36
|
# unique for this kinesis stream.
|
18
37
|
config :application_name, :validate => :string, :default => "logstash"
|
@@ -23,6 +42,15 @@ class LogStash::Inputs::Kinesis < LogStash::Inputs::Base
|
|
23
42
|
# How many seconds between worker checkpoints to dynamodb.
|
24
43
|
config :checkpoint_interval_seconds, :validate => :number, :default => 60
|
25
44
|
|
45
|
+
# Worker metric tracking. By default this is disabled, set it to "cloudwatch"
|
46
|
+
# to enable the cloudwatch integration in the Kinesis Client Library.
|
47
|
+
config :metrics, :validate => [nil, "cloudwatch"], :default => nil
|
48
|
+
|
49
|
+
def initialize(params = {}, kcl_class = KCL::Worker)
|
50
|
+
@kcl_class = kcl_class
|
51
|
+
super(params)
|
52
|
+
end
|
53
|
+
|
26
54
|
def register
|
27
55
|
# the INFO log level is extremely noisy in KCL
|
28
56
|
org.apache.commons.logging::LogFactory.getLog("com.amazonaws.services.kinesis").
|
@@ -30,7 +58,7 @@ class LogStash::Inputs::Kinesis < LogStash::Inputs::Base
|
|
30
58
|
|
31
59
|
worker_id = java.util::UUID.randomUUID.to_s
|
32
60
|
creds = com.amazonaws.auth::DefaultAWSCredentialsProviderChain.new()
|
33
|
-
@
|
61
|
+
@kcl_config = KCL::KinesisClientLibConfiguration.new(
|
34
62
|
@application_name,
|
35
63
|
@kinesis_stream_name,
|
36
64
|
creds,
|
@@ -38,62 +66,33 @@ class LogStash::Inputs::Kinesis < LogStash::Inputs::Base
|
|
38
66
|
end
|
39
67
|
|
40
68
|
def run(output_queue)
|
41
|
-
|
42
|
-
|
43
|
-
@
|
44
|
-
|
45
|
-
|
69
|
+
worker_factory = proc { Worker.new(@codec.clone, output_queue, method(:decorate), @checkpoint_interval_seconds, @logger) }
|
70
|
+
if metrics_factory
|
71
|
+
@kcl_worker = @kcl_class.new(
|
72
|
+
worker_factory,
|
73
|
+
@kcl_config,
|
74
|
+
metrics_factory)
|
75
|
+
else
|
76
|
+
@kcl_worker = @kcl_class.new(
|
77
|
+
worker_factory,
|
78
|
+
@kcl_config)
|
79
|
+
end
|
80
|
+
|
81
|
+
@kcl_worker.run()
|
46
82
|
end
|
47
83
|
|
48
84
|
def teardown
|
49
|
-
@
|
85
|
+
@kcl_worker.shutdown if @kcl_worker
|
50
86
|
end
|
51
87
|
|
52
|
-
|
53
|
-
include com.amazonaws.services.kinesis.clientlibrary.interfaces::IRecordProcessor
|
54
|
-
|
55
|
-
def initialize(*args)
|
56
|
-
# nasty hack, because this is the name of a method on IRecordProcessor, but also ruby's constructor
|
57
|
-
if !@constructed
|
58
|
-
@codec, @output_queue, @decorator, @checkpoint_interval = args
|
59
|
-
@next_checkpoint = Time.now - 600
|
60
|
-
@constructed = true
|
61
|
-
else
|
62
|
-
_shard_id, _ = args
|
63
|
-
@decoder = java.nio.charset::Charset.forName("UTF-8").newDecoder()
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def processRecords(records, checkpointer)
|
68
|
-
records.each { |record| process_record(record) }
|
69
|
-
if Time.now >= @next_checkpoint
|
70
|
-
checkpoint(checkpointer)
|
71
|
-
@next_checkpoint = Time.now + @checkpoint_interval
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def shutdown(checkpointer, reason)
|
76
|
-
if reason == com.amazonaws.services.kinesis.clientlibrary.types::ShutdownReason::TERMINATE
|
77
|
-
checkpoint(checkpointer)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
protected
|
82
|
-
|
83
|
-
def checkpoint(checkpointer)
|
84
|
-
checkpointer.checkpoint()
|
85
|
-
rescue => error
|
86
|
-
@logger.error("Kinesis worker failed checkpointing: #{error}")
|
87
|
-
end
|
88
|
+
protected
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rescue => error
|
96
|
-
@logger.error("Error processing record: #{error}")
|
90
|
+
def metrics_factory
|
91
|
+
case @metrics
|
92
|
+
when nil
|
93
|
+
com.amazonaws.services.kinesis.metrics.impl::NullMetricsFactory.new
|
94
|
+
when 'cloudwatch'
|
95
|
+
nil # default in the underlying library
|
97
96
|
end
|
98
97
|
end
|
99
98
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class LogStash::Inputs::Kinesis::Worker
|
2
|
+
include com.amazonaws.services.kinesis.clientlibrary.interfaces::IRecordProcessor
|
3
|
+
|
4
|
+
attr_reader(
|
5
|
+
:checkpoint_interval,
|
6
|
+
:codec,
|
7
|
+
:decorator,
|
8
|
+
:logger,
|
9
|
+
:output_queue,
|
10
|
+
)
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
# nasty hack, because this is the name of a method on IRecordProcessor, but also ruby's constructor
|
14
|
+
if !@constructed
|
15
|
+
@codec, @output_queue, @decorator, @checkpoint_interval, @logger = args
|
16
|
+
@next_checkpoint = Time.now - 600
|
17
|
+
@constructed = true
|
18
|
+
else
|
19
|
+
_shard_id, _ = args
|
20
|
+
@decoder = java.nio.charset::Charset.forName("UTF-8").newDecoder()
|
21
|
+
end
|
22
|
+
end
|
23
|
+
public :initialize
|
24
|
+
|
25
|
+
def processRecords(records, checkpointer)
|
26
|
+
records.each { |record| process_record(record) }
|
27
|
+
if Time.now >= @next_checkpoint
|
28
|
+
checkpoint(checkpointer)
|
29
|
+
@next_checkpoint = Time.now + @checkpoint_interval
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def shutdown(checkpointer, reason)
|
34
|
+
if reason == com.amazonaws.services.kinesis.clientlibrary.types::ShutdownReason::TERMINATE
|
35
|
+
checkpoint(checkpointer)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def checkpoint(checkpointer)
|
42
|
+
checkpointer.checkpoint()
|
43
|
+
rescue => error
|
44
|
+
@logger.error("Kinesis worker failed checkpointing: #{error}")
|
45
|
+
end
|
46
|
+
|
47
|
+
def process_record(record)
|
48
|
+
raw = @decoder.decode(record.getData).to_s
|
49
|
+
@codec.decode(raw) do |event|
|
50
|
+
@decorator.call(event)
|
51
|
+
@output_queue << event
|
52
|
+
end
|
53
|
+
rescue => error
|
54
|
+
@logger.error("Error processing record: #{error}")
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-kinesis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Brian Palmer
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.0.7
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
name: logstash-core
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
requirement: !ruby/object:Gem::Requirement
|
57
71
|
requirements:
|
@@ -80,6 +94,34 @@ dependencies:
|
|
80
94
|
- - ~>
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '10.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.2.0
|
103
|
+
name: rspec
|
104
|
+
prerelease: false
|
105
|
+
type: :development
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.2.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
name: logstash-codec-json
|
118
|
+
prerelease: false
|
119
|
+
type: :development
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
83
125
|
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
|
84
126
|
email:
|
85
127
|
- brian@codekitchen.net
|
@@ -93,6 +135,7 @@ files:
|
|
93
135
|
- Rakefile
|
94
136
|
- lib/logstash/inputs/kinesis.rb
|
95
137
|
- lib/logstash/inputs/kinesis/version.rb
|
138
|
+
- lib/logstash/inputs/kinesis/worker.rb
|
96
139
|
homepage: https://github.com/codekitchen/logstash-input-kinesis
|
97
140
|
licenses:
|
98
141
|
- Apache License (2.0)
|