Search code examples
regexinfluxdb

influxdb query: specify or filter tag by regex


According to the docs, we can...

Use a regular expression to specify a tag with a value in the WHERE clause.

When I query my influxdb like this, I get the desired results.

> SELECT "field" FROM "measurement" WHERE tag = 19 😀

When replacing the where filtering by a regex, however, I get no results.

> SELECT "field" FROM "measurement" WHERE tag =~ /19/ 😕

Can someone tell me why that is?


Solution

  • Found the mistake myself...

    I had both a field and a tag with the same key. So I was doing

    > SELECT "filed_key" from "measurement" WHERE field_key =~ /val/

    Now I have changed my schema so that keys across fields and tags are unique, and everything works as expected.

    There's also a discussion about this phenomenon on github.