How to convert Epoch Time stamp to basic date time

15 views
Skip to first unread message

its4...@gmail.com

unread,
Sep 22, 2017, 2:04:01 AM9/22/17
to Fluentd Google Group
Hello 

Ho to convert Epoch time stamp to basic date time 

my config file looks like below 

<source>
  type tail
  path /var/log/snmptraps.log
  read_from_head true
  tag snmplog
  format multiline
  format_firstline /^\</
  format1 /(?<time>\d+)(?:,\W)(?<Severity>[^"]+)(?:",\d[\W]+")/
</source>
<match *.**>
  type copy
  <store>
    type elasticsearch
    host localhost
    port 9200
    flush_interval 10s
  </store>
</match>

here I 've to conver the 'time' field to basic date time format as it is coming as epoch in log I tried to change my config as below but its not working 

<source>
  type tail
  path /var/log/snmptraps.log
  read_from_head true
  tag snmplog
  format multiline
  format_firstline /^\</
  format1 /(?<time>\d+)(?:,\W)(?<Severity>[^"]+)(?:",\d[\W]+")/
  time_format ${Time.at(time_format).strftime('%Y-%m-%d %H:%M:%S')}
</source>
<match *.**>
  type copy
  <store>
    type elasticsearch
    host localhost
    port 9200
    logstash_format true
    flush_interval 10s
  </store>
</match>

any help plz?

thanks 
Arun

Reply all
Reply to author
Forward
0 new messages