建立數據庫 curl
curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"
HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: 1e45336f-5e3a-11ea-bd05-000c298be77e
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.9
X-Request-Id: 1e45336f-5e3a-11ea-bd05-000c298be77e
Date: Wed, 04 Mar 2020 17:03:49 GMT
Transfer-Encoding: chunked
{"results":[{"statement_id":0}]}
[root@hfetstlab001p ~]#
寫入數據 curl
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'weather,area=XYZ temperature=10,humidity=30'
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: d501204c-5e3a-11ea-be2c-000c298be77e
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.9
X-Request-Id: d501204c-5e3a-11ea-be2c-000c298be77e
Date: Wed, 04 Mar 2020 17:08:56 GMT
寫入多筆數據 curl
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary '
weather,area=XYZ temperature=13,humidity=30
weather,area=ABC temperature=8,humidity=20
weather,area=XYZ temperature=10,humidity=30
weather,area=ABC temperature=13,humidity=20
'
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: a582ede4-5e3d-11ea-82b0-000c298be77e
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.9
X-Request-Id: a582ede4-5e3d-11ea-82b0-000c298be77e
Date: Wed, 04 Mar 2020 17:29:05 GM
透過檔案寫入 curl
# cat data.txt
weather,area=XYZ temperature=10,humidity=30
weather,area=ABC temperature=3,humidity=20
weather,area=XYZ temperature=11,humidity=35
weather,area=ABC temperature=4,humidity=20
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary @data.txt
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 673d29ff-5e3e-11ea-83e4-000c298be77e
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.9
X-Request-Id: 673d29ff-5e3e-11ea-83e4-000c298be77e
Date: Wed, 04 Mar 2020 17:34:30 GM
不建議檔案數據一次超過5000點
HTTP response summary
2xx: If your write request received `HTTP 204 No Content`, it was a success!
4xx: InfluxDB
5xx: The system is overloaded or significantly impaired.
原始文章(https://docs.influxdata.com/influxdb/v1.7/guides/writing_data/)