Search code examples
prometheusgrafanapromql

PromQL query for specific duration


Stuck on a simple task. The request should only be processed if the request condition is true for more than 10 minutes.

Let's say cpuLoad{instance="1.1.1.1"}>80 It should be output only if this condition is true for more than 10 minutes

I was here https://prometheus.io/docs/prometheus/latest/querying/functions/#time, but nothing helped me)

Query for grafana in prometheus datasource


Solution

  • You can use avg_over_time() as cpuLoad should be instant value.

    Query for CpuLoad for instance="1.1.1.1" should be greater than 80 for more than 10 minutes is
    avg_over_time(cpuLoad{instance="1.1.1.1"}[10m]) > 80