fluent-plugin-kafka 0.4.2.rc1 → 0.4.2
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/ChangeLog +5 -0
- data/fluent-plugin-kafka.gemspec +1 -1
- data/lib/fluent/plugin/in_kafka.rb +22 -1
- data/lib/fluent/plugin/in_kafka_group.rb +22 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3022fed18061233c956a0b13292cbebb9da8a79f
|
4
|
+
data.tar.gz: 5e8f4ecf691f72b620b21358a60f8d8994b9e359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb824c849ef4feb963a1c6675717aadcaea78969ed30285b1d871f9e2a8f62d026489ca660a849a79c4ac8040673ec816b870037647fdde1dc19b7cf772c4f4f
|
7
|
+
data.tar.gz: e1c6ff1982adcac8ce67f0c7f87f94c6b1b497b92f994a4c5c50ac8d55151c01aa2f798dcf7c873ea5158069b835ea92255bc177da972df83b07c641a67c1aaf
|
data/ChangeLog
CHANGED
data/fluent-plugin-kafka.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
13
|
gem.name = "fluent-plugin-kafka"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = '0.4.2
|
15
|
+
gem.version = '0.4.2'
|
16
16
|
gem.required_ruby_version = ">= 2.1.0"
|
17
17
|
|
18
18
|
gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fluent/input'
|
2
|
+
require 'fluent/time'
|
2
3
|
require 'fluent/plugin/kafka_plugin_util'
|
3
4
|
|
4
5
|
class Fluent::KafkaInput < Fluent::Input
|
@@ -31,6 +32,10 @@ class Fluent::KafkaInput < Fluent::Input
|
|
31
32
|
|
32
33
|
config_param :offset_zookeeper, :string, :default => nil
|
33
34
|
config_param :offset_zk_root_node, :string, :default => '/fluent-plugin-kafka'
|
35
|
+
config_param :use_record_time, :bool, :default => false,
|
36
|
+
:desc => "Replace message timestamp with contents of 'time' field."
|
37
|
+
config_param :time_format, :string, :default => nil,
|
38
|
+
:desc => "Time format to be used to parse 'time' filed."
|
34
39
|
|
35
40
|
# Kafka#fetch_messages options
|
36
41
|
config_param :max_bytes, :integer, :default => nil,
|
@@ -49,6 +54,8 @@ class Fluent::KafkaInput < Fluent::Input
|
|
49
54
|
def initialize
|
50
55
|
super
|
51
56
|
require 'kafka'
|
57
|
+
|
58
|
+
@time_parser = nil
|
52
59
|
end
|
53
60
|
|
54
61
|
def configure(conf)
|
@@ -96,6 +103,10 @@ class Fluent::KafkaInput < Fluent::Input
|
|
96
103
|
require 'zookeeper' if @offset_zookeeper
|
97
104
|
|
98
105
|
@parser_proc = setup_parser
|
106
|
+
|
107
|
+
if @use_record_time and @time_format
|
108
|
+
@time_parser = Fluent::TextParser::TimeParser.new(@time_format)
|
109
|
+
end
|
99
110
|
end
|
100
111
|
|
101
112
|
def setup_parser
|
@@ -231,7 +242,17 @@ class Fluent::KafkaInput < Fluent::Input
|
|
231
242
|
|
232
243
|
messages.each { |msg|
|
233
244
|
begin
|
234
|
-
|
245
|
+
record = @parser.call(msg, @topic_entry)
|
246
|
+
if @use_record_time
|
247
|
+
if @time_format
|
248
|
+
record_time = @time_parser.parse(record['time'])
|
249
|
+
else
|
250
|
+
record_time = record['time']
|
251
|
+
end
|
252
|
+
else
|
253
|
+
record_time = Fluent::Engine.now
|
254
|
+
end
|
255
|
+
es.add(record_time, record)
|
235
256
|
rescue => e
|
236
257
|
$log.warn "parser error in #{@topic_entry.topic}/#{@topic_entry.partition}", :error => e.to_s, :value => msg.value, :offset => msg.offset
|
237
258
|
$log.debug_backtrace
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fluent/input'
|
2
|
+
require 'fluent/time'
|
2
3
|
require 'fluent/plugin/kafka_plugin_util'
|
3
4
|
|
4
5
|
class Fluent::KafkaGroupInput < Fluent::Input
|
@@ -20,6 +21,10 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
20
21
|
:desc => "Tag suffix (Optional)"
|
21
22
|
config_param :retry_emit_limit, :integer, :default => nil,
|
22
23
|
:desc => "How long to stop event consuming when BufferQueueLimitError happens. Wait retry_emit_limit x 1s. The default is waiting until BufferQueueLimitError is resolved"
|
24
|
+
config_param :use_record_time, :bool, :default => false,
|
25
|
+
:desc => "Replace message timestamp with contents of 'time' field."
|
26
|
+
config_param :time_format, :string, :default => nil,
|
27
|
+
:desc => "Time format to be used to parse 'time' filed."
|
23
28
|
|
24
29
|
# Kafka consumer options
|
25
30
|
config_param :max_wait_time, :integer, :default => nil,
|
@@ -47,6 +52,8 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
47
52
|
def initialize
|
48
53
|
super
|
49
54
|
require 'kafka'
|
55
|
+
|
56
|
+
@time_parser = nil
|
50
57
|
end
|
51
58
|
|
52
59
|
def _config_to_array(config)
|
@@ -82,6 +89,10 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
82
89
|
@fetch_opts = {}
|
83
90
|
@fetch_opts[:max_wait_time] = @max_wait_time if @max_wait_time
|
84
91
|
@fetch_opts[:min_bytes] = @min_bytes if @min_bytes
|
92
|
+
|
93
|
+
if @use_record_time and @time_format
|
94
|
+
@time_parser = Fluent::TextParser::TimeParser.new(@time_format)
|
95
|
+
end
|
85
96
|
end
|
86
97
|
|
87
98
|
def setup_parser
|
@@ -143,7 +154,17 @@ class Fluent::KafkaGroupInput < Fluent::Input
|
|
143
154
|
|
144
155
|
batch.messages.each { |msg|
|
145
156
|
begin
|
146
|
-
|
157
|
+
record = @parser_proc.call(msg)
|
158
|
+
if @use_record_time
|
159
|
+
if @time_format
|
160
|
+
record_time = @time_parser.parse(record['time'])
|
161
|
+
else
|
162
|
+
record_time = record['time']
|
163
|
+
end
|
164
|
+
else
|
165
|
+
record_time = Fluent::Engine.now
|
166
|
+
end
|
167
|
+
es.add(record_time, record)
|
147
168
|
rescue => e
|
148
169
|
log.warn "parser error in #{batch.topic}/#{batch.partition}", :error => e.to_s, :value => msg.value, :offset => msg.offset
|
149
170
|
log.debug_backtrace
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kafka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.2
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hidemasa Togashi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -125,9 +125,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: 2.1.0
|
126
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
|
-
- - "
|
128
|
+
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: '0'
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
133
|
rubygems_version: 2.5.1
|