Parsing time error in telegraf

Hi,
I am trying to read a csv file (data every 1 second), and I am getting errors reading the time format.
My telegraph configuration has the settings:

csv_timestamp_column = “time”
csv_timestamp_format = “2006-01-22 15:04:05”

when telegraf starts, there are errors and the csv files are not read:

[agent] Config: Interval:1s, Quiet:false, Hostname:“xx.xxx.xxx.xx”, Flush Interval:1s
[inputs.file] Error in plugin: parsing time “2021-01-29 00:09:18” as “2006-01-22 15:04:05”: cannot parse " 00:09:18" as "2"
[inputs.file] Error in plugin: parsing time “time” as “2006-01-22 15:04:05”: cannot parse “time” as "2006"
[inputs.file] Error in plugin: parsing time “time” as “2006-01-22 15:04:05”: cannot parse “time” as "2006"

one line of the csv files is:
2021-01-29 00:09:18,QTRO,1.0,3.022E+0,2.11E+1,1.14E+1, …

I’m a bit lost with the error messages, because according to me, this configuration should read my csv files. Any help will be welcome

I’m running:

  • telegraf 1.21
  • influxdb-1.8.10

telegraf.conf

[global_tags]
user = “db”
[agent]
interval = “1s”
round_interval = false
metric_batch_size = 90000
metric_buffer_limit = 90000
collection_jitter = “0s”
flush_interval = “1s”
flush_jitter = “0s”
[[outputs.influxdb]]
urls = [“http://127.0.0.1:8086”]
skip_database_creation = true
database = “dbd”
password = “xxx”
skip_database_creation = true
[[inputs.file]]
files = ["/datos/*.csv"]
data_format = “csv”
csv_header_row_count = 1
csv_column_names = [“time”,“stn”,“Cycle”,“m31019”,“m43023”,“m45030”,“m57069”,“m59052”,“m69072”,“m73059”,“m79052”,“m87049”,“m93064”,“m105042”,“m107083”,“m115040”,“m121079”]
csv_skip_rows = 0
csv_skip_columns = 0
csv_delimiter = “,”
csv_comment = “”
csv_trim_space = true
csv_tag_columns = [“stn”]
csv_timestamp_column = “time”
csv_timestamp_format = “2006-01-22 15:04:05”

and the data file:

time,stn,Cycle,m31019,m43023,m45030,m57069,m59052,m69072,m73059,m79052,m87049,m93064,m105042,m107083,m115040,m121079
2021-01-29 00:09:18,QTRO,1.0,3.022E+0,2.11E+1,1.14E+1,4.78E+0,5.48E+0,2.93E+0,4.075E+0,8.95E-1,1.51E+0,1.59E+0,7.18E-1,2.61E+0,3.67E-1,8.36E-1
2021-01-29 00:09:19,QTRO,2.0,3.8E+0,2.1E+1,1.1E+1,4.7E+0,7.0E+0,2.5E+0,4.2E+0,6.0E-1,1.0E+0,1.3E+0,9.6E-1,2.50E+0,7.0E-1,9.1E-1
2021-01-29 00:09:20,QTRO,3.0,2.5E+0,2.1E+1,9.1E+0,3.2E+0,6.5E+0,2.7E+0,3.9E+0,2.8E-1,1.1E+0,1.1E+0,1.2E+0,2.7E+0,5.0E-1,9.3E-1

In Golang (and this in telegraf), the actual numbers of the time-format do matter! So what you want is

csv_timestamp_column = “time”
csv_timestamp_format = “2006-01-02 15:04:05”

(2nd of January instead of 22nd ;-)).

1 Like

Did you ever get your issue resolved? I’m having the same issue, in that it appears that the CSV plugin is reading the header row because the error states that is cannot parse “time” (the column name) as “2006”.

@toddwarrington
Please give us an example snippet of your csv data and the telegraf configuration snippet of your input plugin.

The issue had to do with a bug in the 1.21 release. It would read the headers correctly in a single file, but not additional files. The bug seems to be fixed in 1.22.0, and I no longer get the error.
Thanks for the response though.

I don’t understand the fix here … I have the same problem with 1.23 … could you help a bit more … I don’t understand why there is a confusion between 02 and 22 … ?

well … good ideas often come with the night … 2nd of January instead of 22nd … because this is the reference time to use in GO → time package - time - Go Packages

1 Like