fluent-plugin-elasticsearch-timestamp-check 0.2.1 → 0.2.3

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: f860468271772cde0739a1b000e5bc06163bf25c
4
- data.tar.gz: 0ea1133ff3a30c8c840a0f2a193d9ef6de977099
3
+ metadata.gz: 3a0af9963774d5d11e0fd569c18017ba307572c0
4
+ data.tar.gz: 29a7a6840726c287338520259c7c558647426d7f
5
5
  SHA512:
6
- metadata.gz: 059f6f97346bdb6d92767fd479ece1f8ff66113b39b64c92bdd0708c81a175be75805e5da6308265e9582f092a7e0e37931605f3c19e3264e9240ae7897a2fcf
7
- data.tar.gz: 003856228c7ee15a67a3e72a0f21a6eea1b4b8fec8ac6bea7af10fa1adbdc79a3eb4b59e8d7a555b751991fa7c117ac89c3d2108b94b601320b5c49d4f5b2d26
6
+ metadata.gz: e56942ca9ca13036e4d07b7256daa46cd7de5d8e2b55462adb46ef87eea6374cf74c72a2669a6f48eff7d7e7e1d28bd6c6248091835f115aaaf877075b8eafa4
7
+ data.tar.gz: adae81c6a571fc8803c81294da883eb9517b06abaa9a174d5cf6742a754d41b758b72a2eb8b2c923217f8a92cb7134ad8a59a2acfd1a3faa5ea015ab069fbaf5
data/README.md CHANGED
@@ -16,10 +16,11 @@ elasticsearch.
16
16
  * If *@timestamp* field already exists, it will ensure the format is correct
17
17
  by parse and convert to format '%Y-%m-%dT%H:%M:%S%z'.
18
18
 
19
- * If a field named *timestamp* exists, it will parse that field and conver it to
20
- format '%Y-%m-%dT%H:%M:%S%z' then store it in *@timestamp* field.
19
+ * If a field named *timestamp* or *time* or *syslog_timestamp* exists, it will
20
+ parse that field and conver it to format '%Y-%m-%dT%H:%M:%S%z' then store it
21
+ in *@timestamp* field.
21
22
 
22
- * If neither of the above field exists, it will insert current time in
23
+ * If none of the above field exists, it will insert current time in
23
24
  '%Y-%m-%dT%H:%M:%S%z' format as the *@timestamp* field.
24
25
 
25
26
  ## Usage
@@ -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.1"
3
+ spec.version = "0.2.3"
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}
@@ -18,32 +18,24 @@ module Fluent::Plugin
18
18
  end
19
19
 
20
20
  def filter(tag, time, record)
21
- timestamps = [ record['@timestamp'], record['timestamp'], record['time'] ]
22
- valid = false
23
- timestamps.each do |timestamp|
21
+ %w{@timestamp timestamp time syslog_timestamp}.map do |field|
22
+ record[field]
23
+ end.compact.each do |timestamp|
24
24
  begin
25
- if timestamp then
26
- DateTime.parse(timestamp)
27
- valid = timestamp
28
- break
29
- end
25
+ record['@timestamp'] = record['fluent_converted_timestamp'] =
26
+ DateTime.parse(timestamp).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
27
+ $log.debug("Timestamp parsed: #{record['@timestamp']}")
28
+ break
30
29
  rescue ArgumentError
31
- next
32
30
  end
33
31
  end
34
32
 
35
- if valid
36
- record['@timestamp'] =
37
- DateTime.parse(valid).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
38
- record['fluent_converted_timestamp'] =
39
- DateTime.parse(valid).strftime('%Y-%m-%dT%H:%M:%S.%L%z')
40
- $log.debug("Timestamp parsed: #{record['@timestamp']}")
41
- else
42
- record['@timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
43
- record['fluent_added_timestamp'] =
33
+ unless record['fluent_converted_timestamp']
34
+ record['@timestamp'] = record['fluent_added_timestamp'] =
44
35
  Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z')
45
36
  $log.debug("Timestamp added: #{record['@timestamp']}")
46
37
  end
38
+
47
39
  record
48
40
  end
49
41
  end
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.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Li
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-15 00:00:00.000000000 Z
11
+ date: 2017-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler