尽管InfluxDB的curl响应为HTTP 200,但系列未丢失

时间:2019-03-18 19:00:29

标签: curl influxdb

我正在尝试在InfluxDB中将DROP SERIESWITH语句一起使用。我希望使用以下查询删除一些值:

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"}

1 个答案:

答案 0 :(得分:0)

通过使用bash的多行格式,我能够在WSL中解决此问题:

curl -i -XPOST \
> 'http://localhost:8086/query?db=test' \
> --date-urlencode \
> "q=DROP SERIES FROM WHERE "unit"='hPa'"