Influxdb - telegraf - import csv-file into influxdb

Hello,

I want to import this csv-file example.csv into an influxdb with the name PDMCC

example.csv

User;2D;german;41
User;2D;spanish;115
User;2D;mexican;0
User;2D;brasilian;77
User;2D;all;381

the conf for telegraf is pretty simple

bash-4.2$ cat test9.conf

Configuration for telegraf agent

[agent]

Default data collection interval for all inputs

interval = “3s”

If set to true, do no set the “host” tag in the telegraf agent.

omit_hostname = true

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

OUTPUT PLUGINS

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

Configuration for sending metrics to InfluxDB

[[outputs.influxdb]]

urls = [“http://127.0.0.1:8086”]
database = “PDMCC”

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

INPUT PLUGINS

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

Reload and gather from file[s] on telegraf’s interval.

[[inputs.file]]
files = [“example.csv”]
data_format = “csv”
csv_column_names = [“1_category”,“2_type”,“3_item”,“value”]
csv_delimiter = “;”
bash-4.2$

the test-run is OK, every line is taken
bash-4.2$ telegraf -config test9.conf -test

file 1_category=“User”,2_type=“2D”,3_item=“german”,value=41i 1603529684000000000
file 1_category=“User”,2_type=“2D”,3_item=“spanish”,value=115i 1603529684000000000
file 1_category=“User”,2_type=“2D”,3_item=“mexican”,value=0i 1603529684000000000
file 1_category=“User”,2_type=“2D”,3_item=“brasilian”,value=77i 1603529684000000000
file 1_category=“User”,2_type=“2D”,3_item=“all”,value=381i 1603529684000000000
bash-4.2$

but in the influxdb, in the measurement file
only the last line of example.csv arrives

select * from file
name: file
time 1_category 2_type 3_item value


1603529754000000000 User 2D all 381
1603529757000000000 User 2D all 381
1603529760000000000 User 2D all 381
1603529763000000000 User 2D all 381

Can you tell, what is wrong or missing in the config-file?

Hello @apollo25466,
It looks like all of your timestamps are the same, so it’s overwriting with each new point.
Can you try including a timestamp column with different timestamps?

Hi Anais,
Many thanks for supporting me,
My Input file has no timestamp and it will be difficult to change the Scripts which creates the Input fileand I rely on telegraf adding the timestamp, but adding always the timestamp is wrong for the Import Influx.
Is there a way to tell telegraf to create always a diferent timestamp, e.g. by modif of the nanosecond to make it unique?
Bye Michael

Hello @apollo25466,
You can use the execd processor plugin to add timestamps to you data. You can execute this in the language of your choice.