Recording rule eval interval how longe should I can set? less than 5m?

40 views
Skip to first unread message

Allenzh li

unread,
Jan 25, 2021, 7:50:48 AM1/25/21
to Prometheus Users
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?

Stuart Clark

unread,
Jan 25, 2021, 5:30:31 PM1/25/21
to Allenzh li, Prometheus Users
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.

lizhihua0925

unread,
Jan 26, 2021, 2:31:06 AM1/26/21
to Prometheus Users, Stuart Clark

Thank you for your reply.


Got it.

Reply all
Reply to author
Forward
0 new messages