I have a system which demands to monitor its metrics. In order to do that I use grafana + influxdb. The version of influxdb I currently use is 0.9.x.
I want to be able to calculate some statistics. My use case is quite simple:
- I want to make a select query from a few time series sources.
- I want to make group by statement inside the select query to get my data grouped.
- Finally, I want to find the mean value inside each group.
My query is as follows:
SELECT mean(value) FROM /namespaces_.*.amount/ where time < "2015-10-21T14:16:18Z" group by time(1m);
It seems trivial, however, it is a little bit tricky. I get something like this:
name: namespaces_1.amount
------------------------------------------------------------
time mean
1970-01-01T00:00:00Z 0.8877630461283463
name: namespaces_2.amount
------------------------------------------------------------
time mean
1970-01-01T00:00:00Z 0.6982870635693408
According to influxdb documentation, you're able to grab data from multiple sources. In other words, you could write multiple data series after FROM keyword. Whereas I want to merge them and do my processing on merged series. In influxdb 0.8.x there was merge
function which gave you the ability to mix data sources.
However, in influxdb 0.9.x there are neither merge nor join operations.
Ref: https://influxdb.com/docs/v0.9/concepts/08_vs_09.html
In InfluxDB 0.9 neither the MERGE nor JOIN operations are supported. The MERGE operation is no longer needed. All series within a measurement are automatically merged when queried, unless explicitly excluded by tags in the WHERE clause.
So, when you write
SELECT mean(value) FROM merge(/namespaces_.*.amount/) where time < "2015-10-21T14:16:18Z" group by time(1m);
You get an empty result...
Hence, my question is: what is the way to select data from multiple time series sources, merge them, group by some criteria and apply aggregation function to each group using tools of influxdb 0.9.x?