Average Memory Usage Query - Prometheus
Answer :
average memory usage for instances over the past 24 hours
You can use avg_over_time
:
100 * (1 - ((avg_over_time(node_memory_MemFree[24h]) + avg_over_time(node_memory_Cached[24h]) + avg_over_time(node_memory_Buffers[24h])) / avg_over_time(node_memory_MemTotal[24h])))
For CPU, I was able to use irate
irate
only looks at the last two samples, and that query is the inverse of how many modes you have and will be constant (it's always 0.1 on my kernel). You want
100 - (avg by (instance) (rate(node_cpu{job="node",mode="idle"}[5m])) * 100)
Note that this is a 5 minute moving average and you can change [5m]
to whatever period of time you are looking for such as [24h]
.
Update commands
CPU Usage :
(1 - avg(irate(node_cpu_seconds_total{mode="idle"}[10m])) by (instance)) * 100
Memory Usage :
100 * (1 - ((avg_over_time(node_memory_MemFree_bytes[10m]) + avg_over_time(node_memory_Cached_bytes[10m]) + avg_over_time(node_memory_Buffers_bytes[10m])) / avg_over_time(node_memory_MemTotal_bytes[10m])))
Comments
Post a Comment