Sha256: 72c71c80055c271530444016c4b6c3970429b4f75e4b0086425eafe745e46ec9
Contents?: true
Size: 980 Bytes
Versions: 1
Compression:
Stored size: 980 Bytes
Contents
module Fluent class ElasticsearchTimestampCheckFilter < Filter Fluent::Plugin.register_filter('elasticsearch_timestamp_check', self) def configure(conf) super require 'date' end def start super end def shutdown super end def filter(tag, time, record) existing = record['@timestamp'] || record['timestamp'] || record['time'] if existing record['@timestamp'] = DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S.%L%z') record['fluent_converted_timestamp'] = DateTime.parse(existing).strftime('%Y-%m-%dT%H:%M:%S.%L%z') $log.debug("Timestamp parsed: #{record['@timestamp']}") else record['@timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z') record['fluent_added_timestamp'] = Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z') $log.debug("Timestamp added: #{record['@timestamp']}") end record end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-elasticsearch-timestamp-check-0.1.2 | lib/fluent/plugin/filter_elasticsearch_timestamp_check.rb |