I have some data from snort which has two subfields, in an !event¬ fields:
"event-microsecond" => 289367,
"event-second" => 1493741082,
I am trying to compose these into a float and then tell Elasticsearch it's the timestamp field.
filter {
mutate { add_field =>
{ "full_timestamp" => "[event][event-second].[event][event-microsecond]" }
}
mutate { convert => { "full_timestamp" => "float" } }
date {
locale => "en"
match => ["full_timestamp", "UNIX_MS" ]
target => "@timestamp"
}
}
give me 0.0 for the full_timestamp, so I'm doing something wrong when I try to make the new field.
I then tried mutate { add_field => { "full_timestamp" => "%{[event][event-second]}.%{[event][event-microsecond]}" } }
and got
"full_timestamp" => 1493741082.289367,
"@timestamp" => 1970-01-18T06:55:41.082Z,
The new field looks about right, but the date is wrong by miles; it should be 2nd May 2017.
UNIX_MS expects the input to be the time in milliseconds since the epoch, so to get the expected results you'll want full_timestamp to contain 1493741082289. You can use a ruby filter to divide event-microsecond by 1000 to turn it into milliseconds, then use a mutate filter to simply concatenate event-second and event-microsecond (with no intervening decimal point). Well, the concatenation could of course also be done with the same ruby filter.
I suspect I need
'[event][event-second]').to_s + (event.get('[event][event-microsecond]') / 1000000).to_s)
to change microseconds (I had /1000 before, which is milliseconds)
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.