Csv time format

Hi ,
i need help regarding parse time format when wiring data to influxdb by input.tail

my time is input like this

2020-12-21 17:05:+08:00

could any one help with csv_timestamp_format please


The timeformats use the Go “reference time”, of Mon Jan 2 15:04:05 MST 2006. I believe that means it would translate your format to:

2006-01-02 15:04:-0700

@jpowers thanks for supporting bro , timestamp format changed but still didn’t work the points written with last current time , sorry if confused u , but let me provide you the original csv file here it’s :

2022-01-29 17:05:00+02:00,NE=2100724,LINUX_IF,,60,60,0,3,eth10,366786256,0

i tried both with inputs.file & tail , it keep writing data and update each minute and don’t have timestamp

Can you provide the error message you are getting please?

In terms of format, the difference was your new format has the seconds added on, in which case you need to use:

2006-01-02 15:04:05-07:00

Morning @jpowers ,
till now everting going good , there no error after deploy the configuration u provided , but the problem is keep writing points each minute and don’t have timestamp that provided in csv file . thisis my input.tail configuration

 files = ["/etc/telegraf/linux.csv"]
  from_beginning = true
  watch_method = "inotify"
  pipe = false
  max_undelivered_lines = 1000
 data_format = "csv"
 csv_skip_rows = 0
 csv_header_row_count = 1
 csv_delimiter = ","
 csv_tag_columns = []
 csv_measurement_column = "MU"
 csv_timestamp_column = ["collectionBeginTime"]
 csv_timestamp_format = "2006-01-02 15:04:05-0700"

for example each time file updated the points written with existing time that filed uploaded to the path , didnt find any record with timestamp on this date 2022-01-29 17

I’m not sure I follow. Can you provide an example of the input and output you are seeing?

hi @jpowers
here is the output from udp listen

LINUX_IF,host=915ed1fbc543,path=/etc/telegraf/linux.csv Granularity=60i,suspectFlag=0i,hostname="",NEID="NE=2100724",SampleInterval=60i,ifIndex=3i,ifDescr="eth10",ifOutOctets=366786256i,ifOutUcastPkts=0i,collectionBeginTime="2022-01-11 17:05:00+02:00" 1643814417183510975

In your config you have:

csv_timestamp_column = ["collectionBeginTime"]

That should be a string, not an array. In either case this is what I did:

  files = ["data.csv"]
  data_format = "csv"
  csv_header_row_count = 1
  csv_delimiter = ","
  csv_timestamp_column = "collectionBeginTime"
  csv_timestamp_format = "2006-01-02 15:04:05-07:00"

2022-01-29 17:05:00+02:00,NE=2100724,LINUX_IF,,60,60,0,3,eth10,366786256,0
file,host=ryzen Granularity=60i,SampleInterval=60i,ifIndex=3i,ifOutOctets=366786256i,NEID="NE=2100724",MU="LINUX_IF",hostname="",suspectFlag=0i,ifDescr="eth10",ifOutUcastPkts=0i 1643468700000000000

The UNIX timestamp of 1643468700 converts to Jan 29, 2022 as reported in the CSV file. While I am using the file plugin above, you can convert to using tail and add-in options as you get things working.

@jpowers thank you bro for professional support , it’s working perfectly without any issue , thanks for help , you save me

1 Like