I am trying to use DROP SERIES
along with the WITH
statement in InfluxDB. I wish to drop some values using the following query:
DROP SERIES FROM "measurement_name" WHERE "tag_name"='tag_value'
I my case for a test, it should drop all the values from the measurement since I do not have distinct tags.
curl -i -XPOST 'http://localhost:8086/query?db=testNimble' --data-urlencode 'q=drop series from "pressure" where "unit"='hPa''
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/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}]}
However the data still exists:
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
I tried restarting the daemon but the data still exists.
It mentions the that I am trying to query this
"query": "DROP SERIES FROM pressure WHERE unit = hPa"
The Double Quotes and single quotes are not being escaped here.
I tried changing my query with escape for quotes as follows:
curl -X POST 'http://localhost:8086/query?db=test' --data-urlencode 'q=DROP SERIES WHERE "unit"=\'hPa\' '
it then asks for an extra single quote (WHY? all the quotes are closed)
and the reponse throws an error:
{"error":"error parsing query: found \\, expected identifier, string, number, bool at line 1, char 26"}
I was able to solve this issue in WSL by using the multi-line formatting for bash as follows:
curl -i -XPOST \
> 'http://localhost:8086/query?db=test' \
> --date-urlencode \
> "q=DROP SERIES FROM WHERE "unit"='hPa'"