Roman Dryndik
Roman Dryndik

Reputation: 1184

Merging time series in influxdb 0.9.x

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:

  1. I want to make a select query from a few time series sources.
  2. I want to make group by statement inside the select query to get my data grouped.
  3. 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?

Upvotes: 3

Views: 5197

Answers (1)

beckettsean
beckettsean

Reputation: 1836

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?

You need to build your schema correctly, as I responded on the mailing list.

In InfluxDB 0.9, all series under a given measurement are merged by default, and the filtered using tags in the WHERE clause.

Series under different measurements cannot be merged into a single result.

You have many measurements with one series each. You should have few measurements with many series each. See the 0.8 vs 0.9 docs.

Upvotes: 4

Related Questions