Influxdb: Unable to write "multiple points" using HTTP call

Created on 8 Jun 2017  路  13Comments  路  Source: influxdata/influxdb

I'm currently trying to write multiple points into my database using a HTTP call but I can't seem to get it to work. Even the example call given on your documentation isn't working for me. Here's a run down of the different permutations of calls I've tried and what error I'm facing with them.

1 Just one point
curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64'

HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 1d858abf-4c2d-11e7-832c-000000000000
X-Influxdb-Version: 1.2.4
Date: Thu, 08 Jun 2017 09:30:31 GMT

This works. None of the other permutations that I use below work.

2 Two points and no timestamp
curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 flow,host=server02,region=us-west value=0.65'

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: 4b2a3d3a-4c2d-11e7-832d-000000000000
X-Influxdb-Version: 1.2.4
Date: Thu, 08 Jun 2017 09:31:47 GMT
Content-Length: 135

{"error":"unable to parse 'flow,host=server01,region=us-west value=0.64 flow,host=server02,region=us-west value=0.65': bad timestamp"}

3 Two points and one timestamp
curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 flow,host=server02 value=1.2 1496914088'

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: 7251f9b5-4c2d-11e7-832e-000000000000
X-Influxdb-Version: 1.2.4
Date: Thu, 08 Jun 2017 09:32:53 GMT
Content-Length: 134

{"error":"unable to parse 'flow,host=server01,region=us-west value=0.64 flow,host=server02 value=1.2 1496914088': bad timestamp"}

4 Two points and two timestamps
curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 1496914087 flow,host=server02 value=1.2 1496914088'

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: 7251f9b5-4c2d-11e7-832e-000000000000
X-Influxdb-Version: 1.2.4
Date: Thu, 08 Jun 2017 09:32:53 GMT
Content-Length: 134

{"error":"unable to parse 'flow,host=server01,region=us-west value=0.64 1496914087 flow,host=server02 value=1.2 1496914088': bad timestamp"}

1.x wontfix

All 13 comments

add a line break after every point

curl -i -XPOST 'http://localhost:8086/write?db=sensordata' -d 'flow,host=server01,region=us-west value=0.64 **line-break** flow,host=server02,region=us-west value=0.65'

While that might work (I'll confirm once I'm at work) when I manually enter from the command-line, how would I be doing this from a script? There are a few thousand points that I will be pushing to the database. I tried adding \n and \r\n. Any suggestions?

Edit: It does work on my terminal on Ubuntu if I press enter and send the new point but then I wont be able to do that using a script. Is there any way to get around this? I need to be able to automate sending the data to the db and I can't do that this way. I've tried out a few things including the suggestions from:
link

It doesn't work. Sadly. Do you have any suggestions @hvr993 ?

On HP-UX there is a solution
https://github.com/influxdata/influxdb/issues/6636#issuecomment-219941760

But in Linux I couldn't make it today.

It works

data="OIDTCP,pid=123 tcp=2\nOIDTCP,pid=2345 tcp=3"

curl -X POST $url -A "TCP_LOG INFLUX" --data-binary @- <<EOF
`echo -e $data`
EOF

Hi, I am trying to insert data through HTTP post call. Only last point is getting inserted. Could you please help me in this issue.

I can see the data has line break for each point in the http log. But only last point is getting inserted. Kindly help me on this issue.

@carao2020 please provide the example of your POST call.

Hi Alexey,

I am trying to insert below mentioned data.

X12_837,type=A ccn="c123456789"
X12_837,type=A ccn="d123456789"

Please see below screenshot showing the content.

image

In addition, please see below Trace content that shows the HTTP POST call from IBM Transformation Extender HTTP Adapter.

image

Please see below screenshot showing ASCII content of the data that I am trying to insert.

image

Kindly review and let me know for additional information. Thanks

@carao2020 sorry, I cant' reproduce it because I don't have IBM Transformation Extender and it's not easy to install it.

The problem is definetely in new line symbol.

What platform do you have InfluxDB running on? Windows or Linux?


@carao2020 oops, my bad, didn't notice you have identical measurement name, tag set, and timestamp. In this case this is an expected InfluxDB behaviour.

See https://docs.influxdata.com/influxdb/v1.3//troubleshooting/frequently-asked-questions/#how-does-influxdb-handle-duplicate-points

Hi Alexey,

Thank you very much for the details. I am able to resolve this issue now. Thanks once again. :)

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.

i thought this problem not sovled.i want to post multiple points to influxdb by program,not a terminal.
also i don't want to write a file then to post.
i want post by concat a string then post,just like

val data="..."
HttpUtil.post(url,data)

i'm sure add '\n' or '\r\n' doesn't work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FGRibreau picture FGRibreau  路  45Comments

beckettsean picture beckettsean  路  105Comments

beckettsean picture beckettsean  路  81Comments

toddboom picture toddboom  路  69Comments

TechniclabErdmann picture TechniclabErdmann  路  80Comments