fluent-plugin-elasticsearch-timestamp-check 0.1.2 → 0.2.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b723fb7f5bb581fc468368d1b84621373e1e539
|
4
|
+
data.tar.gz: c898e8ee3dd0d463fec076344186b5840a746de4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
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
|
-
|
20
|
-
|
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(
|
36
|
+
DateTime.parse(valid).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
|
23
37
|
record['fluent_converted_timestamp'] =
|
24
|
-
DateTime.parse(
|
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.
|
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:
|
11
|
+
date: 2017-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|