InfluxDB batch insert only inserts the last line


I’m trying to insert some lines into a InfluxDB instance (running on Windows 7 x64) from both a .txt and a .csv file, but it’s only inserting the last line on the file.

I’m currently using the Insomnia interface to send the file through Influx’s HTTP API.

I have the following content inside a data.txt file:

any,mytag=ab value=59
any,mytag=ab value=78
any,mytag=ab value=102

All lines are ending with LF only (verifying it through N++).
Then I send this file via an HTTP request to my running InfluxDB instance:

POST http://localhost:8086/write?db=mydb&precision=ns

Yet, when I do a select * from "any" query, it shows that only the last line (value=102) was inserted.

I’ve also tried inserting through “Content-Type: text/plain” content but to no success as well.

Any idea on this?




I noticed that, apparently, for this to work, you have to include the timestamps on each line as well.
Is there any way to do this kind of inserts without the timestamps?




@tiagomagnuss Are you married to using the http api? Have you considered using telegraf? You could use the tail plugin and it will create a timestamp for you every time a line/lines are added to the .txt file.



@Anaisdg Unfortunately, yes. I’m trying to keep things as reduced as possible (admit I have never installed/setup a Telegraf service, thus I might be wrong on this).

But I thank you for the advice, will surely check more on it on future implementations. :slight_smile:

1 Like


@tiagomagnuss I strongly recommend checking out telegraf. It’s DB agnostic, extremely easy and reliable. There are over 200 input plugins, so it’s also very versatile. Might save you a lot of work!

1 Like