How to create timestamp of YYYY-MM-DD HH:MM:SS.NNNNNN formats in Influxdb using Grok

#1

Hi,

I have a timestamp field that is coming from the log file of ‘YYYY-MM-DD HH:MM:SS.NNNNNN’ format. I want make this as timestamp field in influxdb. i am loading the log using telegraf. So what will be the appropriate grok pattern to load the timestamp field. I have tried with below format but its not working.

%{TIMESTAMP_ISO8601:timestamp:ts-“2018-02-05 12:30:44.927980”}

any ideas or explanations are welcome.

//Regards
Joel T Stephen

#2

You will need to use the “reference time” which is defined as Mon Jan 2 15:04:05 -0700 MST 2006, after converting to your format it should look something like:

%{TIMESTAMP_ISO8601:timestamp:ts-"2006-01-02 15:04:05.999999"}

Let me know if that works

1 Like
#3

Thanks @daniel the pattern is working :relaxed: