尽管来自 InfluxDB 的 curl 响应是 HTTP 200,但系列没有被丢弃
Series not dropped although curl response from InfluxDB is HTTP 200
我正在尝试将 DROP SERIES
与 InfluxDB 中的 WITH
语句一起使用。我希望使用以下查询删除一些值:
DROP SERIES FROM "measurement_name" WHERE "tag_name"='tag_value'
我的测试案例,它应该从测量中删除所有值,因为我没有不同的标签。
cURL
curl -i -XPOST 'http://localhost:8086/query?db=testNimble' --data-urlencode 'q=drop series from "pressure" where "unit"='hPa''
对 InfluxDB 守护进程的响应
2019-03-18T18:36:37.818018Z info Executing query {"log_id": "0EGWa~nl000", "service": "query", "query": "DROP SERIES FROM pressure WHERE unit = hPa"}
[httpd] 127.0.0.1 - - [18/Mar/2019:19:36:37 +0100] "POST /query?db=testNimble HTTP/1.1" 200 33 "-" "curl/7.35.0" c3b5ba54-49ac-11e9-800e-000000000000 0
来自 HTTP 的响应
HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: ebd5b2a4-49ab-11e9-800b-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.6.1
X-Request-Id: ebd5b2a4-49ab-11e9-800b-000000000000
Date: Mon, 18 Mar 2019 18:30:35 GMT
Transfer-Encoding: chunked
{"results":[{"statement_id":0}]}
但是数据仍然存在:
select * from pressure limit 10
name: pressure
time unit v
---- ---- -
1545153813714000000 hPa 101997
1545153814761000000 hPa 102004
1545153816045000000 hPa 102006
1545153817203000000 hPa 102003
1545153818265000000 hPa 102003
1545153819446000000 hPa 102003
1545153820498000000 hPa 102004
1545153821680000000 hPa 102007
1545153822854000000 hPa 102003
1545153823904000000 hPa 102003
我尝试重新启动守护进程,但数据仍然存在。
InfluxD 日志
它提到我正在尝试查询这个
"query": "DROP SERIES FROM pressure WHERE unit = hPa"
此处不对双引号和单引号进行转义。
我尝试使用引号转义来更改我的查询,如下所示:
curl -X POST 'http://localhost:8086/query?db=test' --data-urlencode 'q=DROP SERIES WHERE "unit"=\'hPa\' '
然后它要求额外的单引号(为什么?所有引号都关闭)
响应抛出错误:
{"error":"error parsing query: found \, expected identifier, string, number, bool at line 1, char 26"}
我能够通过使用 bash 的多行格式解决 WSL 中的这个问题,如下所示:
curl -i -XPOST \
> 'http://localhost:8086/query?db=test' \
> --date-urlencode \
> "q=DROP SERIES FROM WHERE "unit"='hPa'"
我正在尝试将 DROP SERIES
与 InfluxDB 中的 WITH
语句一起使用。我希望使用以下查询删除一些值:
DROP SERIES FROM "measurement_name" WHERE "tag_name"='tag_value'
我的测试案例,它应该从测量中删除所有值,因为我没有不同的标签。
cURL
curl -i -XPOST 'http://localhost:8086/query?db=testNimble' --data-urlencode 'q=drop series from "pressure" where "unit"='hPa''
对 InfluxDB 守护进程的响应
2019-03-18T18:36:37.818018Z info Executing query {"log_id": "0EGWa~nl000", "service": "query", "query": "DROP SERIES FROM pressure WHERE unit = hPa"}
[httpd] 127.0.0.1 - - [18/Mar/2019:19:36:37 +0100] "POST /query?db=testNimble HTTP/1.1" 200 33 "-" "curl/7.35.0" c3b5ba54-49ac-11e9-800e-000000000000 0
来自 HTTP 的响应
HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: ebd5b2a4-49ab-11e9-800b-000000000000
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.6.1
X-Request-Id: ebd5b2a4-49ab-11e9-800b-000000000000
Date: Mon, 18 Mar 2019 18:30:35 GMT
Transfer-Encoding: chunked
{"results":[{"statement_id":0}]}
但是数据仍然存在:
select * from pressure limit 10
name: pressure
time unit v
---- ---- -
1545153813714000000 hPa 101997
1545153814761000000 hPa 102004
1545153816045000000 hPa 102006
1545153817203000000 hPa 102003
1545153818265000000 hPa 102003
1545153819446000000 hPa 102003
1545153820498000000 hPa 102004
1545153821680000000 hPa 102007
1545153822854000000 hPa 102003
1545153823904000000 hPa 102003
我尝试重新启动守护进程,但数据仍然存在。
InfluxD 日志
它提到我正在尝试查询这个
"query": "DROP SERIES FROM pressure WHERE unit = hPa"
此处不对双引号和单引号进行转义。
我尝试使用引号转义来更改我的查询,如下所示:
curl -X POST 'http://localhost:8086/query?db=test' --data-urlencode 'q=DROP SERIES WHERE "unit"=\'hPa\' '
然后它要求额外的单引号(为什么?所有引号都关闭)
响应抛出错误:
{"error":"error parsing query: found \, expected identifier, string, number, bool at line 1, char 26"}
我能够通过使用 bash 的多行格式解决 WSL 中的这个问题,如下所示:
curl -i -XPOST \
> 'http://localhost:8086/query?db=test' \
> --date-urlencode \
> "q=DROP SERIES FROM WHERE "unit"='hPa'"