You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
If I want to get an average of memory utilization by dc for dc1 and dc2. I want to use a construction like:
avg(sum(mem.used{dc=~"dc1|dc2"}) by (dc, host) / on(dc, host) mem.total{dc=~"dc1|dc2"}) by (dc) as avg_mem_percent_used
I would expect this expression to produce 2 time series: avg_mem_percent_used{dc=dc1} and avg_mem_percent_used{dc=dc2}
What does it do:
mem.used{dc=~"dc1|dc2"} - selects all mem.used metrics for dc tag is either dc1 or dc2
sum(mem.used{dc=~"dc1|dc2"}) by (dc, host) - computes total of mem.used by dc and host tags. Something like SELECT sum(mem.used) WHERE dc in ('dc1', 'dc2') GROUP BY dc, host
sum(mem.used{dc=~"dc1|dc2"}) by (dc, host) / on(dc, host) mem.total{dc=~"dc1|dc2"} - match result time series from the last step and mem.total by tags with values. on(dc, host) tells to match by dc and host tags only. mem.total has an extra tag host_type so it'll be ignored.
avg(sum(mem.used{dc=~"dc1|dc2"}) by (dc, host) / on(dc, host) mem.total{dc=~"dc1|dc2"}) by (dc) - will take results from the previous step, will group them by dc tag and will compute average for every every group
... as avg_mem_percent_used - will name result metrics as avg_mem_percent_used, tags will be taken from the previous step, it will be dc tag.
This syntax makes expressions much easier to read and understand.
The text was updated successfully, but these errors were encountered:
Prometheus supports several very useful operations to match time series by sets of labels: https://prometheus.io/docs/prometheus/latest/querying/operators/. It would be great if Argus can support the same type of operations.
Here are few examples when this can be useful:
Let's say we have memory usage by applications in different datacenters:
If I want to get an average of memory utilization by dc for dc1 and dc2. I want to use a construction like:
I would expect this expression to produce 2 time series:
avg_mem_percent_used{dc=dc1}
andavg_mem_percent_used{dc=dc2}
What does it do:
mem.used{dc=~"dc1|dc2"}
- selects allmem.used
metrics fordc
tag is eitherdc1
ordc2
sum(mem.used{dc=~"dc1|dc2"}) by (dc, host)
- computes total of mem.used bydc
andhost
tags. Something likeSELECT sum(mem.used) WHERE dc in ('dc1', 'dc2') GROUP BY dc, host
sum(mem.used{dc=~"dc1|dc2"}) by (dc, host) / on(dc, host) mem.total{dc=~"dc1|dc2"}
- match result time series from the last step andmem.total
by tags with values.on(dc, host)
tells to match bydc
andhost
tags only.mem.total
has an extra taghost_type
so it'll be ignored.avg(sum(mem.used{dc=~"dc1|dc2"}) by (dc, host) / on(dc, host) mem.total{dc=~"dc1|dc2"}) by (dc)
- will take results from the previous step, will group them bydc
tag and will compute average for every every group... as avg_mem_percent_used
- will name result metrics asavg_mem_percent_used
, tags will be taken from the previous step, it will bedc
tag.This syntax makes expressions much easier to read and understand.
The text was updated successfully, but these errors were encountered: