Hi all,
I would like to delete data with a certain tag (Measurement = House_WO_WP) and I’m using this command:
influx delete --bucket 'ipsymcon/autogen' --start '2018-03-21T07:24:10.000Z' --stop '2022-10-17T20:36:10.000Z' --predicate 'Measurement="House_WO_WP"' --token 'xyz' --host http://192.168.1.43:8089
But this does not work, I get an error:
Error: failed to delete data: 400 Bad Request: invalid request; error parsing request json: bad logical expression, at position 0
I’m using Influx CLI 2.4.0 (git: 5c7c34f)
What is wrong here?
Thanks!
Oliver
Seems to be a bug:
opened 12:58PM - 15 Apr 22 UTC
closed 04:41PM - 04 Jan 23 UTC
InfluxDB v2.2.0 (git: a2f8538837) build_date: 2022-04-06T17:36:40Z
Hello, I'm… using python to write to the influxdb.
```python
point = influxdb_client.Point('test-measurement')
point.tag('host', 'test-host')
write_api.write(bucket=self._bucket, org=self._org, record=point)
```
now I would like to also be able to delete a Point with a certain tag and time frame.
According to the documentation this is possible:
https://docs.influxdata.com/influxdb/v2.2/write-data/delete-data
To test this I'm using the `influx` command from the package "influxdb2-cli"
**attempt 1**
```bash
influx delete --bucket test-bucket --start '2022-04-15T12:15:04.600Z' --stop '2022-04-15T12:15:13.230Z' --predicate '_measurement="test-measurement" AND host="test-host"'
```
But this returns a `Error: failed to delete data: 400 Bad Request: invalid request; error parsing request json: bad logical expression, at position 32`
**attempt 2**
When losing the tag specification, everything works, but deletes all points between the time frame... (not wanted!)
```bash
influx delete --bucket test-bucket --start '2022-04-15T12:15:04.600Z' --stop '2022-04-15T12:15:13.230Z' --predicate '_measurement="test-measurement"'
```
**attempt 3**
When specifying a non-existing the tag, the command succeeds but deletes nothing...
```bash
influx delete --bucket test-bucket --start '2022-04-15T12:15:04.600Z' --stop '2022-04-15T12:15:13.230Z' --predicate '_measurement="test-measurement" AND testing="test-host"'
```
As attempt 1 and 3 are the same except for the tag name, the 'invalid request comes from the fact that I'm using a tag that exists and things go haywire...
Am I doing things wrong or is this indeed a bug?
But still, if anyone has a workaround here, this would be much appreciated.
Problem seems to be the tag key beeing named “measurement” which is one of the InfluxDB’s keyword and should therefore be avoided.
Using a double-quote around the tag key solved the problem:
[...] --predicate '"Measurement"=House_WO_WP' [...]
Great job in finding the problem!
Jedrek
October 24, 2022, 8:27am
5
I have a similar problem but with deleting °C measurements.
The command from the CLI does not seem to recognize °C,
.\influx delete --bucket homeassistant --start ‘2022-10-03T11:50:00Z’ --stop ‘2022-10-03T13:50:00Z’ --predicate ‘_measurement=“°C” AND entity_id=“dom_temperatura”’ --org dom -token …mytoken…
Error: failed to delete data: 400 Bad Request: invalid request; error parsing request json: bad tag value: “°”, at position 13
Of course, when there is no ° character, delete works fine. Is it a CLI bug or should I write °C differentl?
Same issue for me with OSS 2.6.1 and InfluxQL shell 2.6.1
I have fixed the problem by writting double quotes instead of simple quotes.
In my case :
–predicate “_measurement=“temperature” AND ville=“nice””
instead of
–predicate ‘_measurement=“temperature” AND ville=“nice”’
Nejc
April 24, 2023, 8:57am
7