fluent-plugin-elasticsearch-timestamp-check 0.2.3 → 0.2.4
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: caf11889f096c3937908340a59ff69af610e80a9
|
4
|
+
data.tar.gz: 5fec5fb248ae90cae895942b8d1fb6544e5a233c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4904d97b3143926d00c313bef06a1e3e2f79413f6c867ca2e3cde2bbbf6db46b68960bab98abd0e28c702e849377bd15b5ee2c56a0c5640ece68f77204138c6d
|
7
|
+
data.tar.gz: 3d3e8575835bdb4a9d9e28e70c9abbb7a58ea8cee7a6fc0e97dff92b3ecfb09afd728c928a47b3dbd115d54a5661e1a821ec55ef9c603169a3d2dae7d30bae76
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "fluent-plugin-elasticsearch-timestamp-check"
|
3
|
-
spec.version = "0.2.
|
3
|
+
spec.version = "0.2.4"
|
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}
|
@@ -22,6 +22,21 @@ module Fluent::Plugin
|
|
22
22
|
record[field]
|
23
23
|
end.compact.each do |timestamp|
|
24
24
|
begin
|
25
|
+
# all digit entry would be treated as epoch seconds or epoch millis
|
26
|
+
if !!(timestamp =~ /\A[-+]?\d+\z/)
|
27
|
+
num = timestamp.to_i
|
28
|
+
# epoch second or epoch millis should be either 10 or 13 digits
|
29
|
+
# other length should be considered invalid (until the next digit
|
30
|
+
# rollover at 2286-11-20 17:46:40 Z
|
31
|
+
next unless [10, 13].include?(num.to_s.length)
|
32
|
+
record['@timestamp'] = record['fluent_converted_timestamp'] =
|
33
|
+
Time.at(
|
34
|
+
num / (10 ** (num.to_s.length - 10))
|
35
|
+
).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
|
36
|
+
break
|
37
|
+
end
|
38
|
+
|
39
|
+
# normal timestamp string processing
|
25
40
|
record['@timestamp'] = record['fluent_converted_timestamp'] =
|
26
41
|
DateTime.parse(timestamp).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
|
27
42
|
$log.debug("Timestamp parsed: #{record['@timestamp']}")
|