car,id=0,city=city_0,type=type_0 speed=100,temp=20 1675236656000000000car,id=1,city=city_1,type=type_1 speed=101,temp=21 1675236656000000000car,id=2,city=city_0,type=type_2 speed=102,temp=22 1675236656000000000car,id=3,city=city_1,type=type_0 speed=103,temp=23 1675236656000000000car,id=4,city=city_0,type=type_1 speed=104,temp=24 1675236656000000000car,id=5,city=city_1,type=type_2 speed=105,temp=25 1675236656000000000car,id=0,city=city_0,type=type_0 speed=106,temp=26 1675236657000000000car,id=1,city=city_1,type=type_1 speed=107,temp=27 1675236657000000000car,id=2,city=city_0,type=type_2 speed=108,temp=28 1675236657000000000car,id=3,city=city_1,type=type_0 speed=100,temp=29 1675236657000000000car,id=4,city=city_0,type=type_1 speed=101,temp=30 1675236657000000000car,id=5,city=city_1,type=type_2 speed=102,temp=20 1675236657000000000car,id=0,city=city_0,type=type_0 speed=103,temp=21 1675236658000000000car,id=1,city=city_1,type=type_1 speed=104,temp=22 1675236658000000000car,id=2,city=city_0,type=type_2 speed=105,temp=23 1675236658000000000car,id=3,city=city_1,type=type_0 speed=106,temp=24 1675236658000000000car,id=4,city=city_0,type=type_1 speed=107,temp=25 1675236658000000000car,id=5,city=city_1,type=type_2 speed=108,temp=26 1675236658000000000car,id=0,city=city_0,type=type_0 speed=100,temp=27 1675236659000000000car,id=1,city=city_1,type=type_1 speed=101,temp=28 1675236659000000000car,id=2,city=city_0,type=type_2 speed=102,temp=29 1675236659000000000car,id=3,city=city_1,type=type_0 speed=103,temp=30 1675236659000000000car,id=4,city=city_0,type=type_1 speed=104,temp=20 1675236659000000000car,id=5,city=city_1,type=type_2 speed=105,temp=21 1675236659000000000car,id=0,city=city_0,type=type_0 speed=106,temp=22 1675236660000000000car,id=1,city=city_1,type=type_1 speed=107,temp=23 1675236660000000000car,id=2,city=city_0,type=type_2 speed=108,temp=24 1675236660000000000car,id=3,city=city_1,type=type_0 speed=100,temp=25 1675236660000000000car,id=4,city=city_0,type=type_1 speed=101,temp=26 1675236660000000000car,id=5,city=city_1,type=type_2 speed=102,temp=27 1675236660000000000car,id=0,city=city_0,type=type_0 speed=103,temp=28 1675236661000000000car,id=1,city=city_1,type=type_1 speed=104,temp=29 1675236661000000000car,id=2,city=city_0,type=type_2 speed=105,temp=30 1675236661000000000car,id=3,city=city_1,type=type_0 speed=106,temp=20 1675236661000000000car,id=4,city=city_0,type=type_1 speed=107,temp=21 1675236661000000000car,id=5,city=city_1,type=type_2 speed=108,temp=22 1675236661000000000
CREATEDATABASE<database_name>[WITH[DURATION<duration>[defaultunlimited]>]]
time_series_test_db is as follows.curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode "pretty=true" \\--data-urlencode 'q=CREATE DATABASE time_series_test_db'
{"code": "invalid","message": "Tsdb create database operation is executing, please try again later(maybe failture)."}
{"results": [{"statement_id": 0}]}
show database to view the created database, with the execution format as follows:curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode "pretty=true" \\--data-urlencode 'q=show databases'
[root@VM-16-41-centos ~]# curl --get http://10.16.12.8:8086/query \\> --user "ctsdbi-8ym3****":"test@123" \\> --data-urlencode "pretty=true" \\> --data-urlencode 'q=show databases'{"results": [{"statement_id": 0,"series": [{"name": "databases","columns": ["name"],"columns_types": ["string"],"values": [["test0407"],["time_series_test_db"],["_internal"],["TestAlvinDatabase"],["time_series_test_db0"]]}]}]}
curl -v --data-binary @/tmp/line_protocol_sample.txt \\--user "time_series_test_account":"test_password" \\-H "Content-Type: text/plain" \\-H "Accept: application/json" -X POST \\"http://${influxdb_ip}:8086/write?db=time_series_test_db&precision=ns"
/tmp/test.txt to database time_series_test_db.[root@VM-16-41-centos tmp]# curl -v --data-binary @/tmp/test.txt \\> --user "ctsdbi-8ym3****":"test@123" \\> -H "Content-Type: text/plain" \\> -H "Accept: application/json" -X POST \\> "http://10.16.12.8:8086/write?db=time_series_test_db&precision=ns"* About to connect() to 10.16.12.8 port 8086 (#0)* Trying 10.16.12.8...* Connected to 10.16.12.8 (10.16.12.8) port 8086 (#0)* Server auth using Basic with user 'ctsdbi-8ym3****'> POST /write?db=time_series_test_db&precision=ns HTTP/1.1> Authorization: Basic Y3RzZGJpLTh5********************> User-Agent: curl/7.29.0> Host: 10.16.12.8:8086> Content-Type: text/plain> Accept: application/json> Content-Length: 2552> Expect: 100-continue>* Done waiting for 100-continue< HTTP/1.1 204 No Content< Date: Mon, 10 Apr 2023 03:48:51 GMT< Content-Type: application/json< Content-Length: 0<* Connection #0 to host 10.16.12.8 left intact
Date: Mon, 10 Apr 2023 03:48:51 GMT indicates the time of successful writing completion without any error messages. For common error messages, see the table below.Error Message | Error Meaning | Processing Method |
{ "error": "NotFoundCollection cannot find collections"} | Connection failed. | Troubleshoot whether the private IP address and port connected with the database are correct. |
{ "error": "BadParam ERR wrong password.\\r\\n"} | The account password for accessing the database is incorrect. | Check whether the password information is correct. |
{ "error": "NotFoundAccount ERR account id or name not exists: 1nB3pmg=="} | The account for accessing the data does not exist. | Check whether there is an input error in the account information. |
{ "error": "InvalidFieldFormat ParsePoint() failed|status=InvalidFieldFormat InvalidBooleanFormat not start with tTfF|line=727|col=14\\ncar id=0,city=city_0,type=type_0 speed=100,temp=20 0\\n | start here"} | Data writing failed. | Check if there is a format issue with Line Protocol at the 14th character of this row of data: car id=0,city=city_0,type=type_0 speed=100,temp=20. |
show measurements. The execution method is as follows:curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode 'db=time_series_test_db' \\--data-urlencode "pretty=true" \\--data-urlencode "q=show measurements"
[root@VM-16-41-centos ~]# curl --get http://10.16.12.8:8086/query \\> --user "ctsdbi-8ym3****":"test@123" \\> --data-urlencode 'db=time_series_test_db' \\> --data-urlencode "pretty=true" \\> --data-urlencode "q=show measurements"{"results": [{"statement_id": 0,"series": [{"name": "measurements","columns": ["name"],"columns_types": ["string"],"values": [["car"],["d=0"]]}]}]}
select_stmt = "SELECT" fields from_clause [ where_clause ] [ group_by_clause ] [ order_by_clause ] [ limit_clause ] [ offset_clause ] [ slimit_clause ] [ soffset_clause ] [ sql_order_by_clause ]
Parameter | Parameter Description |
fields | Specifies the list of field(s) to be queried, which can consist of one or more fields, separated by commas. If you need to query all fields, you can use the wildcard "*". |
from_clause | Specifies the name of the measurement to be queried. |
where_clause | Specifies the condition(s) to be queried, which can consist of one or more conditions. Multiple conditions can be combined using logical operators such as AND, OR, and NOT. Conditions include tags and fields, which can be compared using comparison operators (such as =, !=, >, <). |
group_by_clause | Specifies the tag(s) by which the query results need to be grouped, which can consist of one or more tags, separated by commas. |
order_by_clause | Specifies the field(s) by which the query results need to be sorted, which can consist of one or more fields, separated by commas. By default, the query results are sorted by timestamp. |
limit_clause | Specifies the maximum number of rows for the query results. |
offset_clause | Specifies the starting row number for the query results. |
slimit_clause | Similar to limit_clause, but only applies to the result set within each group. |
soffset_clause | Similar to offset_clause, but only applies to the result set within each group. |
sql_order_by_clause | Similar to order_by_clause, but sorts by using SQL syntax. |
curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode 'db=time_series_test_db' \\--data-urlencode "pretty=true" \\--data-urlencode 'q=select * from car'
curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode 'db=time_series_test_db' \\--data-urlencode "pretty=true" \\--data-urlencode 'q=select * from car limit 3 offset 2'
curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode 'db=time_series_test_db' \\--data-urlencode "pretty=true" \\--data-urlencode 'q=select max(speed) as fun1, min(speed) as fun2 from car group by time(3s), type fill(none)'
{"results": [{"statement_id": 0,"series": [{"name": "car","tags": {"type": "type_0"},"columns": ["time","fun1","fun2"],"columns_types": ["time","float","float"],"values": [["2023-02-01T07:30:54Z",103.0,100.0],["2023-02-01T07:30:57Z",106.0,100.0],["2023-02-01T07:31:00Z",106.0,100.0]]},{"name": "car","tags": {"type": "type_1"},"columns": ["time","fun1","fun2"],"columns_types": ["time","float","float"],"values": [["2023-02-01T07:30:54Z",104.0,101.0],["2023-02-01T07:30:57Z",107.0,101.0],["2023-02-01T07:31:00Z",107.0,101.0]]},{"name": "car","tags": {"type": "type_2"},"columns": ["time","fun1","fun2"],"columns_types": ["time","float","float"],"values": [["2023-02-01T07:30:54Z",105.0,102.0],["2023-02-01T07:30:57Z",108.0,102.0],["2023-02-01T07:31:00Z",108.0,102.0]]}]}]}
DELETE FROM<measurement_name>WHERE [<tag_key>='<tag_value>'] | [<time interval>]
curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode 'db=time_series_test_db' \\--data-urlencode "pretty=true" \\--data-urlencode "q=delete from car where city = 'city_0'"
DROP MEASUREMENT<measurement_name>
curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode 'db=time_series_test_db' \\--data-urlencode "pretty=true" \\--data-urlencode 'q=dropmeasurementcar'
DROP DATABASE<database_name>
curl --get http://${influxdb_ip}:8086/query \\--user "time_series_test_account":"test_password" \\--data-urlencode "pretty=true" \\--data-urlencode 'q=DROP DATABASEtime_series_test_db'
{"results": [{"statement_id": 0}]}
Feedback