How to convert nanoseconds to milliseconds


(Steve) #1

Hi,
I have a timestamp as nanoseconds in an access log that I want to store in ES. I understand that the timestamp in ES is stored as milliseconds and that I'll need to convert. Will I have to use mutate and gsub to trim the last six digits from my nanoseconds timestamp? If so how would I go about that?

Thanks, Steve.


(Magnus B├Ąck) #2

You should be able to use a mutate filter,

mutate {
    gsub => ["fieldname", "\d{6}$", ""]
}

or a ruby filter if you want actual arithmetics.


(Steve) #3

Many thanks @magnusbaeck that's exactly what I was looking for.

Thanks, Steve.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.