fluent-plugin-elasticsearch-timestamp-check 0.1.2 → 0.2.0

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
  SHA1:
3
- metadata.gz: e481bd9c704562d1e7ef761c88303c4135f1e294
4
- data.tar.gz: 7b8df7d6997549b899d400ddf283239110c992dc
3
+ metadata.gz: 9b723fb7f5bb581fc468368d1b84621373e1e539
4
+ data.tar.gz: c898e8ee3dd0d463fec076344186b5840a746de4
5
5
  SHA512:
6
- metadata.gz: 10fdcaa2082b797e534566403b440067404ceef6dc4f633181266bb7b0f86f0790bce8f1018c732e7631aaa3b8b4053e50a61af5cc5b8e7e80084733a90106c5
7
- data.tar.gz: bc6a9b174b5ac08a7c0b1dbd5881acbfdd3cd29fafc5ab073ec083189f8302ce3982138d7180d4107c8e0945c46e4cb1a00348b1d1fa324078462b88729d0887
6
+ metadata.gz: 9e5f34fce88a87aef457bb0f1241b17e08a333bb25be5cbe138169c41d306d1fd3d3a49f982ef986f3cb544e6aaf556c321b99134ae4fe4e8c241bc2c26406a8
7
+ data.tar.gz: 1164d64c16a87a4cd6091ce1f8ab60defc70372a6629d3b302d6607814257dcca7eb5b6316fa66095c2840abfaa7e12b98094d137fe3b0c01ae702bed50188ae
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "fluent-plugin-elasticsearch-timestamp-check"
3
- spec.version = "0.1.2"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Richard Li"]
5
5
  spec.email = ["evilcat@wisewolfsolutions.com"]
6
6
  spec.description = %q{fluent filter plugin to ensure @timestamp is in proper format}
@@ -1,4 +1,6 @@
1
- module Fluent
1
+ require 'fluent/plugin/filter'
2
+
3
+ module Fluent::Plugin
2
4
  class ElasticsearchTimestampCheckFilter < Filter
3
5
  Fluent::Plugin.register_filter('elasticsearch_timestamp_check', self)
4
6
 
@@ -16,12 +18,24 @@ module Fluent
16
18
  end
17
19
 
18
20
  def filter(tag, time, record)
19
- existing = record['@timestamp'] || record['timestamp'] || record['time']
20
- if existing
21
+ timestamps = [ record['@timestamp'], record['timestamp'], record['time'] ]
22
+ timestamps.each do |timestamp|
23
+ begin
24
+ DateTime.parse(timestamp)
25
+ valid = timestamp
26
+ break
27
+ rescue ArgumentError
28
+ next
29
+ else
30
+ valid = false
31
+ end
32
+ end
33
+
34
+ if valid
21
35
  record['@timestamp'] =
22
- DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
36
+ DateTime.parse(valid).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
23
37
  record['fluent_converted_timestamp'] =
24
- DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
38
+ DateTime.parse(valid).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
25
39
  $log.debug("Timestamp parsed: #{record['@timestamp']}")
26
40
  else
27
41
  record['@timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elasticsearch-timestamp-check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-21 00:00:00.000000000 Z
11
+ date: 2017-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler