How to import a csv file to influxdb
Recently i needed a way to import csv file to influxdb, of course there was always the option to create something custom, but this would…
Recently i needed a way to import csv file to influxdb, of course there was always the option to create something custom, but this would need extensive changes each time there is such a task.
Doing a fast search i found this one!
Its an excellent tool and very easy to use, here is a simple example:csv-to-influxdb.py -tz Europe/Athens -i /home/kpatronas/job/scripts/get_health/log_utl/output/sum/results.csv --dbname METRICS -tc time -m DB2_LOG_UTIL --tagcolumns db_host --fieldcolumns log_util_perc -s 127.0.0.1:8086
The file that i wanted to import to influx has the following formattime,db_host,log_util_perc
2021-10-16 12:50:05,server3,0.35
2021-10-16 12:50:05,server2,0.03
2021-10-16 12:50:05,server4,0.08
2021-10-16 12:50:05,server1,0.29
Lets do a breakdown of the parameters:
- -tz: Time zone for the timestamps
- -i: the csv file
- dbname: The db to be used
- -tc: which column will be used as a time field
- -m: the name of the measurement
- tagcolumns: the tag, comma separated
- fieldcolumns: the fiels to be used
- -s: the influxdb server
Of course there are many other parameters, but the tool is very much self explaining.
Happy influxdb importing :)