Invalid duration in Prometheus rules

37 views
Skip to first unread message

Tom Gregory

unread,
Jan 25, 2021, 7:30:03 AM1/25/21
to Prometheus Users
To keep things clean, I want to use the duration format suggested in this article in my Prometheus rule configuration e.g.  1h30m

My complete rule configuration then looks like this:

groups:
  - name: general
    rules:
      - alert: Memory
        expr: sum(jvm_memory_used_bytes{area="heap"}) / sum(jvm_memory_max_bytes{area="heap"}) * 100 > 95
        for: 1h30m

Which produces this error message:

loading groups failed" err="/etc/prometheus/rules.yml: not a valid duration string: \"1h30m\"

When I replace 1h30m with 1h the configuration is accepted. Is this duration formation not allowed in rules?

Julius Volz

unread,
Jan 25, 2021, 9:43:15 AM1/25/21
to Tom Gregory, Prometheus Users
Hi Tom,

The composite duration syntax got introduced only in 2.21.0. Your config works fine for me with the latest Prometheus version, so you probably just need to upgrade :)

Regards,
Julius

--
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 prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/4e9607dc-6914-43cc-b127-1ac64477f533n%40googlegroups.com.


--
Julius Volz
PromLabs - promlabs.com

Tom Gregory

unread,
Jan 26, 2021, 8:57:57 AM1/26/21
to Julius Volz, Prometheus Users
Many thanks Julius. Checking for an update will be my first port of call next time.

Tom
Reply all
Reply to author
Forward
0 new messages