Long-term operations in Grafan

How to subtract twice in Grafana ? Or add two together, split into each other, etc ?? I found vague clues on the Internet on how to accept the differences between timeouts, but nothing that really tells me how to do this. I use Grafana v2.0.2 with Influxdb v0.8 and have played a lot with graph controls to discover things like the difference operator, which I can apply, but I have no idea how to use it. I tried to find documentation on this, but the closest I can find is largely silent on this topic, and also looks a bit dated, as the interface has changed since these screenshots were taken.

Thanks!

+6
source share
3 answers

This feature was added as question 177 from Grafana :

Set up two series, click the eye icon to hide them, and place the third with the previous separation.

grafana - graphite queries

This only works in Graphite (I would also like to work on inflow)

+6
source

InfluxDB v0.12 supports the following operations:

Arithmetic operation on the result of the aggregation function:

 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 an arithmetic operation between the results of the aggregation function:

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

not supported by the Grafana graphics editor (but you can record it manually).

+5
source

Another possible solution (which I used only with graphite) is to use the sumSeries and scale functions. To add two time series, do

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

and get the difference do

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

This must be done using a text editor for indicators.

+3
source

Source: https://habr.com/ru/post/986434/


All Articles