On my prometheus database, I have got metrics from three different host, I want to make the average between them, like that I can make aggreagation :
information{application=~"$app",access=~"$access",quantile="0.99", host="prom01"}
information{application=~"$app",access=~"$access",quantile="0.99", host="prom02"}
information{application=~"$app",access=~"$access",quantile="0.99", host="prom03"}
I try to sum those three metrics and sub by three on the only query command, like that :
(information{application=~"$app",access=~"$access",quantile="0.99", host="prom01"} +
information{application=~"$app",access=~"$access",quantile="0.99", host="prom02"} +
information{application=~"$app",access=~"$access",quantile="0.99", host="prom03"})/3
but it does not work<
Moreover, I try the sum + rate, does not work also
sum by (host) (rate(information{application=~"$app",access=~"$access",quantile="0.99"})[5m])
You can do the following:
(scalar(information{application=~"$app",access=~"$access",quantile="0.99", host="prom01"}) +
scalar(information{application=~"$app",access=~"$access",quantile="0.99", host="prom02"}) +
scalar(information{application=~"$app",access=~"$access",quantile="0.99", host="prom03"})
) / 3
but it's easier if you do:
(sum(information{application=~"$app",access=~"$access",quantile="0.99", host=~"prom0(1|2|3)"}))
) / 3
Or simply:
avg(information{application=~"$app",access=~"$access",quantile="0.99", host=~"prom0(1|2|3)"})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.