Move data from .csv to influxdb

I’m trying to get data from a csv file to influx to then use the data in Grafana.

The csv file is already populated with 4 columns and many rows (1000).
The 1 row is naming each different column.
1st column is the time is second
2nd to 4th columns are temperature from 3 differents sensors.

If I understood well, I need to write a telegraf.conf configuring file to get my dtata in InfluxDB…
But writting that file isn’t easy, I mean difficult !

hi,

You need to use inputs.file plugin in telegraf. Something like that

time / measurement / sensors1 / sensor2 / sensor3 (row 1)

[[inputs.file]]
files = [“full_path_csv_file”]
data_format = “csv”
csv_header_row_count = 1
csv_delimiter = “,”
csv_measurement_column = “measurement”
csv_timestamp_column = “time”

@meruem

Yes I found that on the documentation.

But I don’t know how I should include it in the telegraf.conf !
Should I remove everythings else ? I guess no. But what to keep ? And what to remove;
That telegraf.conf is so long !
And all few example found are for computer system monitoring.
Sorry for being so stupid.

You also answered my question on InfluxDB communityt forum (but no solution yet)

@har66

If you keep the default telegraf.conf it’s very difficult to read.

First just save this file (rename it like telegraf.conf.backup)

Create a new empty telegraf.conf file. Below a short exemple of that file.

Configuration for telegraf agent
[agent]
interval = “1m”
round_interval = true
precision = “”
hostname = “meruem”
logfile = “/var/log/telegraf/telegraf.log”

###############################################################################

OUTPUT PLUGINS
###############################################################################

Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
urls = [“http://192.168.0.25:8086”]
database = “statistics”

###############################################################################

INPUT PLUGINS
################################################################################

[[inputs.exec]]
files = [“full_path_csv_file”]
data_format = “csv”
csv_header_row_count = 1
csv_delimiter = “,”
csv_measurement_column = “measurement”
csv_timestamp_column = “time”
csv_timestamp_format = “2006-01-02T15:04:05Z07:00”

You can test this configuration with “telegraf --test”

useful link : https://github.com/influxdata/telegraf/tree/master/plugins/parsers/csv

Alternative way

https://www.influxdata.com/blog/getting-started-writing-data-to-influxdb/