fluent-plugin-elasticsearch 3.4.0 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.md +3 -0
- data/fluent-plugin-elasticsearch.gemspec +1 -1
- data/lib/fluent/plugin/out_elasticsearch.rb +18 -3
- data/test/plugin/test_out_elasticsearch.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1ff650a7dd92dbe450e0e4bc6ee1c8b4db2e104d3b50b56aee885e1e06fa4a
|
4
|
+
data.tar.gz: 653c6a1d031fc876a43774336cd2eb5388c4c540f88874fd281640279e003e39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ba9e19a4c955eb8f3b85f0d07523c8ad2d21a041de16aaaa916e6761d5d653077c607e69374c1ea61e87eb804a9322ed76371adbd8b90fbd0f0f8c5d0b91b28
|
7
|
+
data.tar.gz: 449d5f8db19a1e01cc77af21384d003a4d59d33c204de61b2d6dfb3a9476c0721d20c22780fd26428b01cc411738ca4860b2d3cb47a73cc4a404d3d9c5c710d0
|
data/History.md
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'fluent-plugin-elasticsearch'
|
6
|
-
s.version = '3.4.
|
6
|
+
s.version = '3.4.1'
|
7
7
|
s.authors = ['diogo', 'pitr']
|
8
8
|
s.email = ['pitr.vern@gmail.com', 'me@diogoterror.com']
|
9
9
|
s.description = %q{Elasticsearch output plugin for Fluent event collector}
|
@@ -12,6 +12,7 @@ end
|
|
12
12
|
require 'fluent/plugin/output'
|
13
13
|
require 'fluent/event'
|
14
14
|
require 'fluent/error'
|
15
|
+
require 'fluent/time'
|
15
16
|
require_relative 'elasticsearch_constants'
|
16
17
|
require_relative 'elasticsearch_error'
|
17
18
|
require_relative 'elasticsearch_error_handler'
|
@@ -358,18 +359,32 @@ EOC
|
|
358
359
|
# Strptime doesn't support all formats, but for those it does it's
|
359
360
|
# blazingly fast.
|
360
361
|
strptime = Strptime.new(@time_key_format)
|
361
|
-
Proc.new { |value|
|
362
|
+
Proc.new { |value|
|
363
|
+
value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)
|
364
|
+
strptime.exec(value).to_datetime
|
365
|
+
}
|
362
366
|
rescue
|
363
367
|
# Can happen if Strptime doesn't recognize the format; or
|
364
368
|
# if strptime couldn't be required (because it's not installed -- it's
|
365
369
|
# ruby 2 only)
|
366
|
-
Proc.new { |value|
|
370
|
+
Proc.new { |value|
|
371
|
+
value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)
|
372
|
+
DateTime.strptime(value, @time_key_format)
|
373
|
+
}
|
367
374
|
end
|
368
375
|
else
|
369
|
-
Proc.new { |value|
|
376
|
+
Proc.new { |value|
|
377
|
+
value = convert_numeric_time_into_string(value) if value.is_a?(Numeric)
|
378
|
+
DateTime.parse(value)
|
379
|
+
}
|
370
380
|
end
|
371
381
|
end
|
372
382
|
|
383
|
+
def convert_numeric_time_into_string(numeric_time, time_key_format = "%Y-%m-%d %H:%M:%S.%N%z")
|
384
|
+
numeric_time_parser = Fluent::NumericTimeParser.new(:float)
|
385
|
+
Time.at(numeric_time_parser.parse(numeric_time).to_r).strftime(time_key_format)
|
386
|
+
end
|
387
|
+
|
373
388
|
def parse_time(value, event_time, tag)
|
374
389
|
@time_parser.call(value)
|
375
390
|
rescue => e
|
@@ -1711,6 +1711,20 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1711
1711
|
assert_equal(index_cmds[1]['@timestamp'], ts)
|
1712
1712
|
end
|
1713
1713
|
|
1714
|
+
def test_uses_custom_time_key_with_float_record
|
1715
|
+
driver.configure("logstash_format true
|
1716
|
+
time_precision 3
|
1717
|
+
time_key vtm\n")
|
1718
|
+
stub_elastic
|
1719
|
+
time = Time.now
|
1720
|
+
float_time = time.to_f
|
1721
|
+
driver.run(default_tag: 'test') do
|
1722
|
+
driver.feed(sample_record.merge!('vtm' => float_time))
|
1723
|
+
end
|
1724
|
+
assert(index_cmds[1].has_key? '@timestamp')
|
1725
|
+
assert_equal(index_cmds[1]['@timestamp'], time.to_datetime.iso8601(3))
|
1726
|
+
end
|
1727
|
+
|
1714
1728
|
def test_uses_custom_time_key_with_format
|
1715
1729
|
driver.configure("logstash_format true
|
1716
1730
|
time_key_format %Y-%m-%d %H:%M:%S.%N%z
|
@@ -1725,6 +1739,22 @@ class ElasticsearchOutput < Test::Unit::TestCase
|
|
1725
1739
|
assert_equal("logstash-2001.02.03", index_cmds[0]['index']['_index'])
|
1726
1740
|
end
|
1727
1741
|
|
1742
|
+
def test_uses_custom_time_key_with_float_record_and_format
|
1743
|
+
driver.configure("logstash_format true
|
1744
|
+
time_key_format %Y-%m-%d %H:%M:%S.%N%z
|
1745
|
+
time_key vtm\n")
|
1746
|
+
stub_elastic
|
1747
|
+
ts = "2001-02-03 13:14:01.673+02:00"
|
1748
|
+
time = Time.parse(ts)
|
1749
|
+
current_zone_offset = Time.now.to_datetime.offset
|
1750
|
+
float_time = time.to_f
|
1751
|
+
driver.run(default_tag: 'test') do
|
1752
|
+
driver.feed(sample_record.merge!('vtm' => float_time))
|
1753
|
+
end
|
1754
|
+
assert(index_cmds[1].has_key? '@timestamp')
|
1755
|
+
assert_equal(index_cmds[1]['@timestamp'], DateTime.parse(ts).new_offset(current_zone_offset).iso8601(9))
|
1756
|
+
end
|
1757
|
+
|
1728
1758
|
def test_uses_custom_time_key_with_format_without_logstash
|
1729
1759
|
driver.configure("include_timestamp true
|
1730
1760
|
index_name test
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-elasticsearch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- diogo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-04-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|