Telegraf and a csv file

I’m working on getting telegraph to insert a csv file values into influx, and only the last line on the csv is getting written.

###Telegraph confg####
[[inputs.file]]
files = [“C:/telegraf/csv/*.csv”]
data_format = “csv”
csv_header_row_count = 1
csv_skip_rows = 1
csv_delimiter = “,”
csv_comment = “#”
interval = “86400s”

###csv file structure"###
#TYPE Selected.Microsoft.ActiveDirectory.Management.ADUser
“Displayname”,“ExpiryDate”
“User name1”,“7/21/2020 8:39:00 AM”
“User name2”,“5/11/2020 9:43:04 AM”
“User name3”,“7/7/2020 9:10:41 AM”
“User name4”,“5/17/2020 2:42:21 PM”
“User name5”,“6/9/2020 4:59:18 PM”

The log file doesn’t show any errors and only User name5 is getting written to influx. I’ve also looking into using tail and that doesn’t work at all.

Thanks

Hello @mattroell,
Welcome! Hmm can you help me understand your csv better? I see a measurement name and a timestamp but no field value. What is your field?

HI @Anaisdg,

I haven’t added more data to the cvs yet, I’m testing to make sure that it works before I commit more time into it. I thought with the data that I have currently have, that it would work.

Thanks

Hello @mattroell,
I believe you need a field if you want ExpiryDate to be interpreted as a timestamp. I believe it’s interpreting the ExpiryDate as a field of string type.

Here’s an example repo and accompanying blog post with a csv and telegraf config if you want to play with something before diving in.

You’ll also need to include
csv_timestamp_column and csv_timestamp_format

By default the current time will be used for all created metrics, to set the time using the JSON document you can use the csv_timestamp_column and csv_timestamp_format options together to set the time to a value in the parsed document.

The csv_timestamp_column option specifies the key containing the time value and csv_timestamp_format must be set to unix, unix_ms, unix_us, unix_ns, or a format string in using the Go “reference time” which is defined to be the specific time: Mon Jan 2 15:04:05 MST 2006.

You’ll want to convert your timestamps to either unix or Go "reference time (
“2006-01-02T15:04:05Z07:00”)

Also, please try setting debug = True in your telegraf config to help you debug Telegraf. :slight_smile:

Thanks @Anaisdg,

With information you’ve provided I should be able to figure this out.

1 Like

@mattroell,
If not just let me know!

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