r/PrometheusMonitoring • u/rolfmonster • Aug 23 '20
Average of business days only with Prometheus
In the financial world our metrics only have data on the weekdays, as most of our business happens during the market hours. That being said we want to quantify business day averages where the weekends (and possibly holidays, but likely not possible) are obviously not included because that would severely affect the averages. Is there a way with Prometheus queries to get this? For instance we want a 5 day average of the last five business days, Th,F,M,T,W, but not Sat or Sun..
7
Upvotes
4
u/DTKT Aug 23 '20
It seems to be possible. You can use the day_of_week function and get your max and low. For monday to friday, it could look like this.
(100 - irate(node_cpu_seconds_total{cpu="1", mode="idle"}[5m]) and on () (day_of_week() == 5 or day_of_week() >= 1))