fluent-plugin-record-reformer 0.9.0 → 0.9.1
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.md +6 -0
- data/{example.conf → example/example.conf} +3 -3
- data/example/workers.conf +5 -0
- data/fluent-plugin-record-reformer.gemspec +1 -1
- data/lib/fluent/plugin/out_record_reformer/core.rb +4 -0
- data/test/helper.rb +42 -17
- data/test/test_out_record_reformer.rb +77 -77
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a717722e65d7aece7073303d2231c6d441362612
|
4
|
+
data.tar.gz: b8417dd2ca5425ea7dbc692598ce7190ccacff64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d76f1d8acf8fb44942b49c5453dbf571667ab4e8f04805efa13c5431b5288b5f60215433c06bda677fd02b6225045b7948f95a831708a5939a0004508f59b8f
|
7
|
+
data.tar.gz: c1d3de259f79c65ea8c833da2d66eab150841285001b2ce65ebe996b239f081f04b978499e4510483d5a2c09c0ea3e26889c7b9708f248f43bb651efa6683a20
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
<source>
|
2
|
-
type dummy
|
2
|
+
@type dummy
|
3
3
|
tag dummy
|
4
4
|
dummy {"message":"foo","time":1432732710,"members":["Alice"]}
|
5
5
|
</source>
|
6
6
|
|
7
7
|
<match dummy>
|
8
|
-
type record_reformer
|
8
|
+
@type record_reformer
|
9
9
|
renew_time_key time
|
10
10
|
tag reformed.${tag}
|
11
11
|
enable_ruby true
|
@@ -16,5 +16,5 @@
|
|
16
16
|
</match>
|
17
17
|
|
18
18
|
<match reformed.**>
|
19
|
-
type stdout
|
19
|
+
@type stdout
|
20
20
|
</match>
|
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "fluent-plugin-record-reformer"
|
6
|
-
gem.version = "0.9.
|
6
|
+
gem.version = "0.9.1"
|
7
7
|
gem.authors = ["Naotoshi Seo"]
|
8
8
|
gem.email = "sonots@gmail.com"
|
9
9
|
gem.homepage = "https://github.com/sonots/fluent-plugin-record-reformer"
|
data/test/helper.rb
CHANGED
@@ -29,6 +29,27 @@ module Fluent
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
## v0.14
|
33
|
+
# d = create_driver(conf, syntax: :v1)
|
34
|
+
# d.run(default_tag: @tag) do
|
35
|
+
# d.feed(time, record)
|
36
|
+
# end
|
37
|
+
# d.events
|
38
|
+
#
|
39
|
+
## v0.12
|
40
|
+
# d = create_driver(conf, use_v1, default_tag: @tag)
|
41
|
+
# d.run do
|
42
|
+
# d.emit(record, time)
|
43
|
+
# end
|
44
|
+
# d.emits
|
45
|
+
#
|
46
|
+
## Ours
|
47
|
+
# d = create_driver(conf, syntax: :v1, default_tag: @tag)
|
48
|
+
# d.run do
|
49
|
+
# d.feed(time, record)
|
50
|
+
# end
|
51
|
+
# d.events
|
52
|
+
|
32
53
|
require 'fluent/version'
|
33
54
|
major, minor, patch = Fluent::VERSION.split('.').map(&:to_i)
|
34
55
|
if major > 0 || (major == 0 && minor >= 14)
|
@@ -44,32 +65,36 @@ if major > 0 || (major == 0 && minor >= 14)
|
|
44
65
|
@tag = tag
|
45
66
|
end
|
46
67
|
|
47
|
-
def configure(conf, use_v1)
|
48
|
-
super(conf, syntax: use_v1 ? :v1 : :v0)
|
49
|
-
end
|
50
|
-
|
51
68
|
def run(&block)
|
52
69
|
super(default_tag: @tag, &block)
|
53
70
|
end
|
54
|
-
|
55
|
-
def emit(record, time)
|
56
|
-
feed(time, record)
|
57
|
-
end
|
58
|
-
|
59
|
-
def emits
|
60
|
-
events
|
61
|
-
end
|
62
71
|
end
|
63
72
|
|
64
|
-
def create_driver(conf,
|
65
|
-
|
73
|
+
def create_driver(conf, syntax: :v1, default_tag: nil)
|
74
|
+
default_tag ||= @tag
|
75
|
+
RecordReformerOutputTestDriver.new(Fluent::Plugin::RecordReformerOutput, default_tag).configure(conf, syntax: syntax)
|
66
76
|
end
|
67
|
-
else
|
77
|
+
else # <= v0.12e
|
68
78
|
def event_time(str)
|
69
79
|
Time.parse(str)
|
70
80
|
end
|
71
81
|
|
72
|
-
|
73
|
-
|
82
|
+
class RecordReformerOutputTestDriver < Fluent::Test::OutputTestDriver
|
83
|
+
def configure(conf, syntax: :v1)
|
84
|
+
syntax == :v1 ? super(conf, true) : super(conf, false)
|
85
|
+
end
|
86
|
+
|
87
|
+
def feed(time, record)
|
88
|
+
emit(record, time)
|
89
|
+
end
|
90
|
+
|
91
|
+
def events
|
92
|
+
emits
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def create_driver(conf, syntax: :v1, default_tag: nil)
|
97
|
+
default_tag ||= @tag
|
98
|
+
RecordReformerOutputTestDriver.new(Fluent::RecordReformerOutput, default_tag).configure(conf, syntax: :v1)
|
74
99
|
end
|
75
100
|
end
|
@@ -5,20 +5,20 @@ require 'fluent/plugin/out_record_reformer'
|
|
5
5
|
Fluent::Test.setup
|
6
6
|
|
7
7
|
class RecordReformerOutputTest < Test::Unit::TestCase
|
8
|
-
def
|
9
|
-
d = create_driver(config,
|
8
|
+
def feed(config, msgs: [''], syntax: :v1)
|
9
|
+
d = create_driver(config, syntax: syntax, default_tag: @tag)
|
10
10
|
d.run do
|
11
11
|
records = msgs.map do |msg|
|
12
12
|
next msg if msg.is_a?(Hash)
|
13
13
|
{ 'eventType0' => 'bar', 'message' => msg }
|
14
14
|
end
|
15
15
|
records.each do |record|
|
16
|
-
d.
|
16
|
+
d.feed(@time, record)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
@instance = d.instance
|
21
|
-
d.
|
21
|
+
d.events
|
22
22
|
end
|
23
23
|
|
24
24
|
setup do
|
@@ -42,23 +42,23 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
42
42
|
message ${hostname} ${tag_parts.last} ${URI.escape(message)}
|
43
43
|
]
|
44
44
|
|
45
|
-
[
|
45
|
+
[:v1, :v0].each do |syntax|
|
46
46
|
sub_test_case 'configure' do
|
47
47
|
test 'typical usage' do
|
48
48
|
assert_nothing_raised do
|
49
|
-
create_driver(CONFIG,
|
49
|
+
create_driver(CONFIG, syntax: syntax)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
test "tag is not specified" do
|
54
54
|
assert_raise(Fluent::ConfigError) do
|
55
|
-
create_driver('',
|
55
|
+
create_driver('', syntax: syntax)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
test "keep_keys must be specified together with renew_record true" do
|
60
60
|
assert_raise(Fluent::ConfigError) do
|
61
|
-
create_driver(%[keep_keys a],
|
61
|
+
create_driver(%[keep_keys a], syntax: syntax)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -66,9 +66,9 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
66
66
|
sub_test_case "test options" do
|
67
67
|
test 'typical usage' do
|
68
68
|
msgs = ['1', '2']
|
69
|
-
|
70
|
-
assert_equal 2,
|
71
|
-
|
69
|
+
events = feed(CONFIG, syntax: syntax, msgs: msgs)
|
70
|
+
assert_equal 2, events.size
|
71
|
+
events.each_with_index do |(tag, time, record), i|
|
72
72
|
assert_equal("reformed.#{@tag}", tag)
|
73
73
|
assert_equal('bar', record['eventType0'])
|
74
74
|
assert_equal(@hostname, record['hostname'])
|
@@ -81,8 +81,8 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
81
81
|
test '(obsolete) output_tag' do
|
82
82
|
config = %[output_tag reformed.${tag}]
|
83
83
|
msgs = ['1']
|
84
|
-
|
85
|
-
|
84
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
85
|
+
events.each_with_index do |(tag, time, record), i|
|
86
86
|
assert_equal("reformed.#{@tag}", tag)
|
87
87
|
end
|
88
88
|
end
|
@@ -99,8 +99,8 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
99
99
|
</record>
|
100
100
|
]
|
101
101
|
msgs = ['1', '2']
|
102
|
-
|
103
|
-
|
102
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
103
|
+
events.each_with_index do |(tag, time, record), i|
|
104
104
|
assert_equal("reformed.#{@tag}", tag)
|
105
105
|
assert_equal('bar', record['eventType0'])
|
106
106
|
assert_equal(@hostname, record['hostname'])
|
@@ -112,8 +112,8 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
112
112
|
|
113
113
|
test 'remove_keys' do
|
114
114
|
config = CONFIG + %[remove_keys eventType0,message]
|
115
|
-
|
116
|
-
|
115
|
+
events = feed(config, syntax: syntax)
|
116
|
+
events.each_with_index do |(tag, time, record), i|
|
117
117
|
assert_equal("reformed.#{@tag}", tag)
|
118
118
|
assert_not_include(record, 'eventType0')
|
119
119
|
assert_equal(@hostname, record['hostname'])
|
@@ -126,8 +126,8 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
126
126
|
test 'renew_record' do
|
127
127
|
config = CONFIG + %[renew_record true]
|
128
128
|
msgs = ['1', '2']
|
129
|
-
|
130
|
-
|
129
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
130
|
+
events.each_with_index do |(tag, time, record), i|
|
131
131
|
assert_equal("reformed.#{@tag}", tag)
|
132
132
|
assert_not_include(record, 'eventType0')
|
133
133
|
assert_equal(@hostname, record['hostname'])
|
@@ -148,8 +148,8 @@ class RecordReformerOutputTest < Test::Unit::TestCase
|
|
148
148
|
</record>
|
149
149
|
EOC
|
150
150
|
msgs = times.map{|t| t.to_s }
|
151
|
-
|
152
|
-
|
151
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
152
|
+
events.each_with_index do |(tag, time, record), i|
|
153
153
|
assert_equal("reformed.#{@tag}", tag)
|
154
154
|
assert_equal(times[i].to_i, time)
|
155
155
|
assert_true(record.has_key?('event_time_key'))
|
@@ -168,8 +168,8 @@ EOC
|
|
168
168
|
EOC
|
169
169
|
times = [ Time.at(event_time("2010-05-04 03:02:02")), Time.at(event_time("2010-05-04 03:02:03")) ]
|
170
170
|
msgs = times.map{|t| t.to_s }
|
171
|
-
|
172
|
-
|
171
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
172
|
+
events.each_with_index do |(tag, time, record), i|
|
173
173
|
assert_equal("reformed.#{@tag}", tag)
|
174
174
|
assert_equal(times[i].to_i, time)
|
175
175
|
assert_false(record.has_key?('event_time_key'))
|
@@ -179,8 +179,8 @@ EOC
|
|
179
179
|
test 'keep_keys' do
|
180
180
|
config = %[tag reformed.${tag}\nrenew_record true\nkeep_keys eventType0,message]
|
181
181
|
msgs = ['1', '2']
|
182
|
-
|
183
|
-
|
182
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
183
|
+
events.each_with_index do |(tag, time, record), i|
|
184
184
|
assert_equal("reformed.#{@tag}", tag)
|
185
185
|
assert_equal('bar', record['eventType0'])
|
186
186
|
assert_equal(msgs[i], record['message'])
|
@@ -196,8 +196,8 @@ EOC
|
|
196
196
|
</record>
|
197
197
|
]
|
198
198
|
msgs = ['1', '2']
|
199
|
-
|
200
|
-
|
199
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
200
|
+
events.each_with_index do |(tag, time, record), i|
|
201
201
|
assert_equal("reformed.#{@tag}", tag)
|
202
202
|
assert_equal("#{@hostname} ", record['message'])
|
203
203
|
end
|
@@ -215,8 +215,8 @@ EOC
|
|
215
215
|
message ${hostname}
|
216
216
|
</record>
|
217
217
|
]
|
218
|
-
|
219
|
-
|
218
|
+
events = feed(config, syntax: syntax)
|
219
|
+
events.each do |(tag, time, record)|
|
220
220
|
assert_equal(@hostname, record['message'])
|
221
221
|
end
|
222
222
|
end
|
@@ -229,8 +229,8 @@ EOC
|
|
229
229
|
message ${tag}
|
230
230
|
</record>
|
231
231
|
]
|
232
|
-
|
233
|
-
|
232
|
+
events = feed(config, syntax: syntax)
|
233
|
+
events.each do |(tag, time, record)|
|
234
234
|
assert_equal(@tag, record['message'])
|
235
235
|
end
|
236
236
|
end
|
@@ -244,8 +244,8 @@ EOC
|
|
244
244
|
</record>
|
245
245
|
]
|
246
246
|
expected = "#{@tag.split('.').first} #{@tag.split('.').last}"
|
247
|
-
|
248
|
-
|
247
|
+
events = feed(config, syntax: syntax)
|
248
|
+
events.each do |(tag, time, record)|
|
249
249
|
assert_equal(expected, record['message'])
|
250
250
|
end
|
251
251
|
end
|
@@ -259,8 +259,8 @@ EOC
|
|
259
259
|
</record>
|
260
260
|
]
|
261
261
|
expected = "#{@tag.split('.').first} #{@tag.split('.').last}"
|
262
|
-
|
263
|
-
|
262
|
+
events = feed(config, syntax: syntax)
|
263
|
+
events.each do |(tag, time, record)|
|
264
264
|
assert_equal(expected, record['message'])
|
265
265
|
end
|
266
266
|
end
|
@@ -275,8 +275,8 @@ EOC
|
|
275
275
|
]
|
276
276
|
@tag = 'prefix.test.tag.suffix'
|
277
277
|
expected = "prefix.test prefix.test.tag tag.suffix test.tag.suffix"
|
278
|
-
|
279
|
-
|
278
|
+
events = feed(config, syntax: syntax)
|
279
|
+
events.each do |(tag, time, record)|
|
280
280
|
assert_equal(expected, record['message'])
|
281
281
|
end
|
282
282
|
end
|
@@ -289,8 +289,8 @@ EOC
|
|
289
289
|
message ${time}
|
290
290
|
</record>
|
291
291
|
]
|
292
|
-
|
293
|
-
|
292
|
+
events = feed(config, syntax: syntax)
|
293
|
+
events.each do |(tag, time, record)|
|
294
294
|
assert_equal(Time.at(time).localtime.to_s, record['message'])
|
295
295
|
end
|
296
296
|
end
|
@@ -306,8 +306,8 @@ EOC
|
|
306
306
|
</record>
|
307
307
|
]
|
308
308
|
msgs = ['1', '2']
|
309
|
-
|
310
|
-
|
309
|
+
events = feed(config, syntax: syntax, msgs: msgs)
|
310
|
+
events.each_with_index do |(tag, time, record), i|
|
311
311
|
assert_not_include(record, 'eventType0')
|
312
312
|
assert_equal("bar", record['eventtype'])
|
313
313
|
assert_equal("bar #{msgs[i]}", record['message'])
|
@@ -326,8 +326,8 @@ EOC
|
|
326
326
|
</record>
|
327
327
|
]
|
328
328
|
records = [{'tag' => 'tag', 'time' => 'time'}]
|
329
|
-
|
330
|
-
|
329
|
+
events = feed(config, syntax: syntax, msgs: records)
|
330
|
+
events.each do |(tag, time, record)|
|
331
331
|
assert_not_equal('tag', record['new_tag'])
|
332
332
|
assert_equal(@tag, record['new_tag'])
|
333
333
|
assert_not_equal('time', record['new_time'])
|
@@ -346,7 +346,7 @@ EOC
|
|
346
346
|
</record>
|
347
347
|
]
|
348
348
|
msgs = ['1', '2']
|
349
|
-
es =
|
349
|
+
es = feed(config, syntax: syntax, msgs: msgs)
|
350
350
|
es.each_with_index do |(tag, time, record), i|
|
351
351
|
assert_equal({"hostname" => @hostname, "tag" => @tag, "#{@tag}" => 100}, record['hash_field'])
|
352
352
|
end
|
@@ -361,7 +361,7 @@ EOC
|
|
361
361
|
</record>
|
362
362
|
]
|
363
363
|
msgs = ['1', '2']
|
364
|
-
es =
|
364
|
+
es = feed(config, syntax: syntax, msgs: msgs)
|
365
365
|
es.each_with_index do |(tag, time, record), i|
|
366
366
|
assert_equal([@hostname, @tag], record['array_field'])
|
367
367
|
end
|
@@ -376,13 +376,13 @@ EOC
|
|
376
376
|
</record>
|
377
377
|
]
|
378
378
|
msgs = ['1', '2']
|
379
|
-
es =
|
379
|
+
es = feed(config, syntax: syntax, msgs: msgs)
|
380
380
|
es.each_with_index do |(tag, time, record), i|
|
381
381
|
assert_equal([{"tag" => @tag}], record['mixed_field'])
|
382
382
|
end
|
383
383
|
end
|
384
384
|
|
385
|
-
if
|
385
|
+
if syntax == :v1
|
386
386
|
# works with only v1 config
|
387
387
|
test "keys with placeholders with enable_ruby #{enable_ruby}" do
|
388
388
|
config = %[
|
@@ -395,7 +395,7 @@ EOC
|
|
395
395
|
</record>
|
396
396
|
]
|
397
397
|
msgs = ['1', '2']
|
398
|
-
es =
|
398
|
+
es = feed(config, syntax: syntax, msgs: msgs)
|
399
399
|
es.each_with_index do |(tag, time, record), i|
|
400
400
|
assert_equal({@hostname=>'hostname',"foo.#{@tag}"=>'tag'}, record)
|
401
401
|
end
|
@@ -444,7 +444,7 @@ EOC
|
|
444
444
|
:with_suffix => "#{nil.to_s}-suffix" },
|
445
445
|
]
|
446
446
|
actual_results = []
|
447
|
-
es =
|
447
|
+
es = feed(config, syntax: syntax, msgs: msgs)
|
448
448
|
es.each_with_index do |(tag, time, record), i|
|
449
449
|
actual_results << {
|
450
450
|
:single => record["single"],
|
@@ -498,7 +498,7 @@ EOC
|
|
498
498
|
:with_suffix => "#{nil.to_s}-suffix" },
|
499
499
|
]
|
500
500
|
actual_results = []
|
501
|
-
es =
|
501
|
+
es = feed(config, syntax: syntax, msgs: msgs)
|
502
502
|
es.each_with_index do |(tag, time, record), i|
|
503
503
|
actual_results << {
|
504
504
|
:single => record["single"],
|
@@ -520,12 +520,12 @@ EOC
|
|
520
520
|
_foo_bar ${record["foo.bar"]}
|
521
521
|
</record>
|
522
522
|
]
|
523
|
-
d = create_driver(config,
|
523
|
+
d = create_driver(config, syntax: syntax)
|
524
524
|
record = {
|
525
525
|
"foo.bar" => "foo.bar",
|
526
526
|
"@timestamp" => 10,
|
527
527
|
}
|
528
|
-
es =
|
528
|
+
es = feed(config, syntax: syntax, msgs: [record])
|
529
529
|
es.each_with_index do |(tag, time, r), i|
|
530
530
|
assert { r['_timestamp'] == record['@timestamp'] }
|
531
531
|
assert { r['_foo_bar'] == record['foo.bar'] }
|
@@ -541,10 +541,10 @@ EOC
|
|
541
541
|
message ${unknown}
|
542
542
|
</record>
|
543
543
|
]
|
544
|
-
d = create_driver(config,
|
544
|
+
d = create_driver(config, syntax: syntax)
|
545
545
|
mock(d.instance.log).warn("record_reformer: unknown placeholder `${unknown}` found")
|
546
|
-
d.run { d.
|
547
|
-
assert_equal 1, d.
|
546
|
+
d.run { d.feed(@time, {}) }
|
547
|
+
assert_equal 1, d.events.size
|
548
548
|
end
|
549
549
|
|
550
550
|
test 'failed to expand record field (enable_ruby yes)' do
|
@@ -555,12 +555,12 @@ EOC
|
|
555
555
|
message ${unknown['bar']}
|
556
556
|
</record>
|
557
557
|
]
|
558
|
-
d = create_driver(config,
|
558
|
+
d = create_driver(config, syntax: syntax)
|
559
559
|
mock(d.instance.log).warn("record_reformer: failed to expand `%Q[\#{unknown['bar']}]`", anything)
|
560
|
-
d.run { d.
|
561
|
-
#
|
562
|
-
assert_equal 1, d.
|
563
|
-
d.
|
560
|
+
d.run { d.feed(@time, {}) }
|
561
|
+
# feed, but nil value
|
562
|
+
assert_equal 1, d.events.size
|
563
|
+
d.events.each do |(tag, time, record)|
|
564
564
|
assert_nil(record['message'])
|
565
565
|
end
|
566
566
|
end
|
@@ -570,11 +570,11 @@ EOC
|
|
570
570
|
tag ${unknown['bar']}
|
571
571
|
enable_ruby yes
|
572
572
|
]
|
573
|
-
d = create_driver(config,
|
573
|
+
d = create_driver(config, syntax: syntax)
|
574
574
|
mock(d.instance.log).warn("record_reformer: failed to expand `%Q[\#{unknown['bar']}]`", anything)
|
575
|
-
d.run { d.
|
576
|
-
# nil tag message should not be
|
577
|
-
assert_equal 0, d.
|
575
|
+
d.run { d.feed(@time, {}) }
|
576
|
+
# nil tag message should not be feedted
|
577
|
+
assert_equal 0, d.events.size
|
578
578
|
end
|
579
579
|
|
580
580
|
test 'expand fields starting with @ (enable_ruby no)' do
|
@@ -585,10 +585,10 @@ EOC
|
|
585
585
|
foo ${@timestamp}
|
586
586
|
</record>
|
587
587
|
]
|
588
|
-
d = create_driver(config,
|
588
|
+
d = create_driver(config, syntax: syntax)
|
589
589
|
message = {"@timestamp" => "foo"}
|
590
|
-
d.run { d.
|
591
|
-
d.
|
590
|
+
d.run { d.feed(@time, message) }
|
591
|
+
d.events.each do |(tag, time, record)|
|
592
592
|
assert_equal message["@timestamp"], record["foo"]
|
593
593
|
end
|
594
594
|
end
|
@@ -603,10 +603,10 @@ EOC
|
|
603
603
|
foo ${record.map{|k,v|v}}
|
604
604
|
</record>
|
605
605
|
]
|
606
|
-
d = create_driver(config,
|
606
|
+
d = create_driver(config, syntax: syntax)
|
607
607
|
message = {"@timestamp" => "foo"}
|
608
|
-
d.run { d.
|
609
|
-
d.
|
608
|
+
d.run { d.feed(@time, message) }
|
609
|
+
d.events.each do |(tag, time, record)|
|
610
610
|
assert_equal [message["@timestamp"]], record["foo"]
|
611
611
|
end
|
612
612
|
end
|
@@ -619,16 +619,16 @@ EOC
|
|
619
619
|
foo ${__send__("@timestamp")}
|
620
620
|
</record>
|
621
621
|
]
|
622
|
-
d = create_driver(config,
|
622
|
+
d = create_driver(config, syntax: syntax)
|
623
623
|
message = {"@timestamp" => "foo"}
|
624
|
-
d.run { d.
|
625
|
-
d.
|
624
|
+
d.run { d.feed(@time, message) }
|
625
|
+
d.events.each do |(tag, time, record)|
|
626
626
|
assert_equal message["@timestamp"], record["foo"]
|
627
627
|
end
|
628
628
|
end
|
629
629
|
end
|
630
630
|
|
631
|
-
test "compatibility test (enable_ruby yes) (
|
631
|
+
test "compatibility test (enable_ruby yes) (syntax: #{syntax})" do
|
632
632
|
config = %[
|
633
633
|
tag tag
|
634
634
|
enable_ruby yes
|
@@ -642,7 +642,7 @@ EOC
|
|
642
642
|
_foo_bar ${__send__('foo.bar')}
|
643
643
|
</record>
|
644
644
|
]
|
645
|
-
d = create_driver(config,
|
645
|
+
d = create_driver(config, syntax: syntax)
|
646
646
|
record = {
|
647
647
|
"number" => "-",
|
648
648
|
"hex" => "0x10",
|
@@ -650,8 +650,8 @@ EOC
|
|
650
650
|
"@timestamp" => 10,
|
651
651
|
"message" => "10",
|
652
652
|
}
|
653
|
-
|
654
|
-
|
653
|
+
events = feed(config, syntax: syntax, msgs: [record])
|
654
|
+
events.each_with_index do |(tag, time, r), i|
|
655
655
|
assert { r['_message'] == "prefix-#{record['message']}-suffix" }
|
656
656
|
assert { r['_time'] == Time.at(@time) }
|
657
657
|
assert { r['_number'] == 0 }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-record-reformer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -124,7 +124,8 @@ files:
|
|
124
124
|
- LICENSE
|
125
125
|
- README.md
|
126
126
|
- Rakefile
|
127
|
-
- example.conf
|
127
|
+
- example/example.conf
|
128
|
+
- example/workers.conf
|
128
129
|
- fluent-plugin-record-reformer.gemspec
|
129
130
|
- lib/fluent/plugin/out_record_reformer.rb
|
130
131
|
- lib/fluent/plugin/out_record_reformer/core.rb
|
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
154
|
version: '0'
|
154
155
|
requirements: []
|
155
156
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.6.
|
157
|
+
rubygems_version: 2.6.11
|
157
158
|
signing_key:
|
158
159
|
specification_version: 4
|
159
160
|
summary: Fluentd plugin to add or replace fields of a event record
|