How to delete values based on non-existence of a tag

Old topic, but let me document a solution I just used.

I had a series with a missing tag and reinserted them with the tag. This created a problem with the increase() function in my case.

The way you can remove data that does not contain a tag is a bit cumbersome but possible.
Since the delete function only works with measurementname and tags you can use this to minimize the amount of data you need to export.

  1. Export the data you need to keep using CLI wit flux query.
    In my case export all measurements from EnergyMeters without the engunit tag.
"c:\Program Files\influxdb\influx.exe" query "from(bucketID: \"8b63d7f8570aaab6\") |> range(start: 2026-01-29T11:00:00Z, stop: 2026-01-29T17:00:00Z) |> filter(fn: (r) => r._measurement == \"EnergyMeter\") |> filter(fn: (r) => exists r.engunit)" --raw > c:\EnergyMeters.csv
  1. Convert it to a *.lp-file using a dryrun (might not be necessary, I had this already written down somewhere, reading the docs now it seems to be possible to import a csv directly).
"c:\Program Files\influxdb\influx.exe" write dryrun --bucket my-temp-bucket --format csv --file c:\EnergyMeters.csv> c:\EnergyMeters.lp
  1. Delete all data in the timeframe while specifying the same filter used in the export query.
"c:\Program Files\influxdb\influx.exe" delete --bucket-id 8b63d7f8570aaab6 --predicate "_measurement=\"EnergyMeter\"" --start 2026-01-29T11:00:00Z --stop 2026-01-29T17:00:00Z
  1. Reimport the correct data
"c:\Program Files\influxdb\influx.exe" write --bucket-id 8b63d7f8570aaab6 --file c:\EnergyMeters.lp

A hughe flaw of influxdb in my opinion is that you can’t edit the metadata that makes up a series. This makes simple things like adding a tag to a measurement verry difficult.

Same issue:
Delete measurements without specified tag