Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-timeseries operations in Grafana

How do I subtract two timeseries in Grafana? Or add two together, divide one by another, etc...? I have found vague hints online about taking differences between timeseries, but nothing that actually tells me how to do so. I'm using Grafana v2.0.2 with Influxdb v0.8 and have played around with the graph controls enough to discover things like the difference operator I can apply, but I have no idea how to use it. I've attempted to find documentation on this, but the closest I can find is pretty much silent on this topic, and also looks to be slightly out of date, as the interface has changed since those screenshots were taken.

Thanks!

like image 590
staticfloat Avatar asked May 03 '15 04:05

staticfloat


3 Answers

Another possible solution (that I've only tried with graphite) is to use the sumSeries and scale functions. To add two time seriers together, do

sumSeries(first.time.series, second.time.series)

and to get the difference do

sumSeries(first.time.series, scale(second.time.series, -1))

This must be done using the text editor for metrics.

like image 54
Johannes Hoff Avatar answered Nov 02 '22 02:11

Johannes Hoff


This feature has been added as issue 177 of Grafana:

Setup two series, click the eye icon to hide them and put a third with the division of the preceding ones.

grafana - graphite queries

This is only working in Graphite (I'd like it to work on influx badly also)

like image 39
XFMoulet Avatar answered Nov 02 '22 02:11

XFMoulet


InfluxDB v0.12 support following operations:

Arithmetic operation on aggregation function result:

SELECT 10* MEAN(usage_system) AS avg 
FROM cpu WHERE time > now() - 10s;

or arithmetic operation between fields:

SELECT usage_system + usage_user AS avg 
FROM cpu WHERE time > now() - 10s;

and most importantly you can perform arithmetic operation between aggregation function results:

SELECT MEAN(usage_system) + MEAN(usage_user) AS avg 
FROM cpu
  WHERE time > now() - 10s 
  GROUP BY host;

It's not supported by Grafana GUI editor yet (but you can write it in manual mode).

like image 6
Tombart Avatar answered Nov 02 '22 02:11

Tombart