Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

influxdb query: specify or filter tag by regex

Tags:

regex

influxdb

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?

like image 682
creimers Avatar asked Mar 28 '17 17:03

creimers


People also ask

How do I query data from InfluxDB?

To perform an InfluxQL query, send a GET request to the /query endpoint, set the URL parameter db as the target database, and set the URL parameter q as your query. You can also use a POST request by sending the same parameters either as URL parameters or as part of the body with application/x-www-form-urlencoded .

What is the difference between flux and InfluxQL?

InfluxQL lets you group by tags or by time intervals, but nothing else. Flux lets you group by any column in the dataset, including _value . Use the Flux group() function to define which columns to group data by.

What query language does InfluxDB use?

InfluxQL is an SQL-like query language for interacting with data in InfluxDB. The following sections detail InfluxQL's SELECT statement and useful query syntax for exploring your data.


1 Answers

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.

like image 77
creimers Avatar answered Sep 22 '22 09:09

creimers