I am using the Prometheus recording rule to capture the CPU usage over 5 mins and later want to use it to get maximum CPU used for 5 mins in the last 30 days with max_over_time(instance:node_cpu_usage:rate5m[30d]).
- expr: 1 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))
record: instance:node_cpu_usage:rate5m
Suppose a new node is getting scraped by Prometheus and the first few values for "instance:node_cpu_usage:rate5m" will be very high since there is no data for the first 5 mins and the rate for them will be very less. And doing max_over_time on will result in the wrong.
So, is there a way to limit the recording rule to start after 5 mins or so or ask rate function to do the calculation for the data it has?
What happens when I do rate(metricsX[5m]) but only 1 min of data is present?