/write 1.x compatibility API
If you have an existing bucket that doesn’t follow the database/retention-policy naming convention, you must manually create a database and retention policy mapping to write data to that bucket with the /write
compatibility API.
Use one of the following authentication methods:
- token authentication
- basic authentication with username and password
- query string authentication with username and password
Include your line protocol in the request body. Binary encode the line protocol to prevent unintended formatting. The examples use the curl --data-binary
flag to binary encode the line protocol.
(Optional) The 1.x username to authenticate the request. See query string authentication.
(Required) The database to write data to. This is mapped to an InfluxDB . See Database and retention policy mapping.
The retention policy to write data to. This is mapped to an InfluxDB . See Database and retention policy mapping.
ns
- nanoseconds- or
µ
- microseconds ms
- millisecondss
- secondsm
- minutesh
- hours
Write data using basic authentication
curl --request POST http://localhost:8086/write?db=mydb \
--user "INFLUX_USERNAME:INFLUX_PASSWORD_OR_TOKEN" \
Write data using token authentication
Write data to a non-default retention policy
curl --request POST http://localhost:8086/write?db=mydb&rp=customrp \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000000000"
Write multiple lines of line protocol
Write data with millisecond Unix timestamps
curl --request POST http://localhost:8086/write?db=mydb&precision=ms \
--header "Authorization: Token INFLUX_API_TOKEN" \
--data-binary "measurement,host=host1 field1=2i,field2=2.0 1577836800000"
Use curl to write data from a file
Replace the following:
INFLUX_USERNAME
:- : InfluxDB 1.x password or InfluxDB API token