Convert @timestamp to epoch

you can use the ruby filter for this:

input { generator { count => 1 } }
filter {
  # for logstash 5.x
  ruby { code => "event.set('epoc', event.get('@timestamp').to_i)" }
  # for logstash 2.x
  # ruby { code => "event['epoc'] = event['@timestamp'].to_i" }
}
output { stdout { codec => rubydebug } }
{
          "epoc" => 1478082411,
      "sequence" => 0,
    "@timestamp" => 2016-11-02T10:26:51.303Z,
      "@version" => "1",
          "host" => "Joaos-MBP-5.lan",
       "message" => "Hello world!"
}
3 Likes