On 25/01/2021 12:50, Allenzh li wrote:
I want to count the average value of each hour of a metric and I have created a recording rule as follow:
```
    - name: inspection-platform-CVMAndPhysical
      interval: 1h
      rules:
        - record: vm:xxx_cpu_usage:avg1h
          expr: avg_over_time(avg by (label1, lable2) (xxxx_cpu_usage)[1h:])
```

When I make a range query request to the recording data with step > 5m, return empty.

I have google some case find that range query just eval 5m in every step.

So how should I use recording rule?

As with all metrics (scraped or created via recording rule) you need to be setting the scrape/interval to less than 5 minutes otherwise a metric will be marked as stale and not returned. In practice 2 minutes is the maximum sensible scrape interval, and while you could make it a bit longer for recording rules it still needs to be short enough to ensure there is never more than 5 minutes between points.

--
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/e0df84c7-9c72-2ef0-0fa0-374d3b20c3ba%40Jahingo.com.

Reply via email to