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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e8eed03eaeddf3765e1ac07f5038cd026bacbc7f86d63b286af4da186c7d04f
4
- data.tar.gz: 17d90e2717897e2a021629b4414c475954ff0100c16b9d4db2526e8bd4ffc084
3
+ metadata.gz: 0b1ff650a7dd92dbe450e0e4bc6ee1c8b4db2e104d3b50b56aee885e1e06fa4a
4
+ data.tar.gz: 653c6a1d031fc876a43774336cd2eb5388c4c540f88874fd281640279e003e39
5
5
  SHA512:
6
- metadata.gz: 94d36c2a7804887d9f974e26d55a2abbd8ade8e042126f5f6b7bbc586db0ff63fe6195feb8a51d5c610e8ffbc9274d76a886290f49af10ce0ff005d72758fb81
7
- data.tar.gz: 0b3bfaf992cfebd919cdc526c52e5b3200cc70cc424bce51a197cc7915890e9b495904ce367cdb329df69b182c6928675d6872f9ce4e579d55cb2f9e5b53304d
6
+ metadata.gz: 1ba9e19a4c955eb8f3b85f0d07523c8ad2d21a041de16aaaa916e6761d5d653077c607e69374c1ea61e87eb804a9322ed76371adbd8b90fbd0f0f8c5d0b91b28
7
+ data.tar.gz: 449d5f8db19a1e01cc77af21384d003a4d59d33c204de61b2d6dfb3a9476c0721d20c22780fd26428b01cc411738ca4860b2d3cb47a73cc4a404d3d9c5c710d0
data/History.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  ### [Unreleased]
4
4
 
5
+ ### 3.4.1
6
+ - Handle non-String value on parse_time (#570)
7
+
5
8
  ### 3.4.0
6
9
  - Check exclusive feature on #configure (#569)
7
10
  - Modify FAQ for highly load k8s EFK stack (#566)
@@ -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.0'
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| strptime.exec(value).to_datetime }
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| DateTime.strptime(value, @time_key_format) }
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| DateTime.parse(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.0
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-03-28 00:00:00.000000000 Z
12
+ date: 2019-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd