Error while writing an alert rule in alert.yml file

18 views
Skip to first unread message

Isabel Noronha

unread,
Jun 19, 2020, 10:20:06 AM6/19/20
to Prometheus Users
 This is just code snippet of my alerts.yml file
- alert: ContainerKilled
    expr: IF absent(((time() - container_last_seen{name=".+"}) < 5))
    for: 15s
    labels:
      severity: warning
    annotations:
      summary: "Container killed (instance {{ $labels.instance }})"
      description: "A container has been killed\n  VALUE = {{ $value }}\n  LABELS: {{ $labels }}"

Could anyone tell me what am I doing wrong in this rule?
It's throwing error :parse error: unexpected identifier \"absent\""

Christian Hoffmann

unread,
Jun 19, 2020, 10:52:34 AM6/19/20
to Isabel Noronha, Prometheus Users
Hi,
The "IF" doesn't belong there. Try removing it. :)

Kind regards,
Christian

Isabel Noronha

unread,
Jun 22, 2020, 9:48:19 AM6/22/20
to Prometheus Users
Thanks that worked.
So absent can be used only when a job is known (eg. job=" Jenkins") or can it be used generically with any kind of label?
So my requirement is to send an alert when a container goes down.
So I create a service that has a minimum of  1k container. So I cannot hardcode the container names.
Is there a way to get alerts when a container is down for sure?
I have already used container_last_seen but it is not so accurate.

Any help would be appreciated.

Thanks,
Regards,
Isabel
Reply all
Reply to author
Forward
0 new messages