I have same problem.
In my case I have 2 retention policies:
- raw_data (data falls into this RP every 30 sec);
- downsampled_data_5m (data from RP raw_data aggregates into this RP every 5 minutes).
At Grafana dashboard I have variable $retention_policy, that equals to raw_data and downsampled_data_5m.
My ordinary queries look like this:
SELECT /^usage_system$|^mean_usage_system$/ FROM "$retention_policy"."cpu" WHERE ("host" =~ /$server$/ and "cpu" = 'cpu-total')
So I have ability to switch value of variable $retention_policy and show data from different RP.
But sometimes there is a need to perform arithmetic operations with result of queries. For example, there is no metric in Telegraf that shows usage of inodes in percent:
show field keys from disk
To calculate free inodes in percent I need to perform query like this:
SELECT "inodes_used" / "inodes_total" * 100 FROM "disk"
For case described above I need to add regexp into query like this:
SELECT (/^inodes_used$|mean_inodes_used$/ / /^inodes_total$|^mean_inodes_total$/ * 100) FROM "disk"
But regular expressions doesn’t work in queries with mathematic operations. Is it possible to add support of them?