본문 바로가기

STUDY

[influxDB] How to write more fields in influxDB with HTTP API

When I saw the influxDB with HTTP API reference(https://docs.influxdata.com/influxdb/v1.7/tools/api/), I could see the examples that only one field is inserted to influxDB. I wanted to insert one more fields with HTTP API.

For examples, suppose you create a database named 'mydb' and you want to insert one tag named 'host' and two fields ('a', 'b') in table named 'test'. In this case, you can do it by running the below command on console.

curl -i -XPOST 'http://localhost:8086/write?db=mydb' -u your_id:your_passwd --data-binary 'test,host=your_host a=some_value,b=some_value epoch_time'

If you want to control the time in influxDB, you can set it by typing a space and epoch time at the end.

During I tried to use influxDB with HTTP API, I faced an error that is '{"error":"unable to parse authentication credentials"}. I solved it by adding option in command that is '-u your_id:your_passwd'. But, If you don't face like this error, you don't need to type '-u your_id:your_passwd'. Refer to https://docs.influxdata.com/influxdb/v1.7/tools/api/