VictoriaMetrics / operator

Kubernetes operator for Victoria Metrics
Apache License 2.0
403 stars 141 forks source link

vmalert: add template variable to hold the "for:" alert rule value #995

Open rcowham opened 1 week ago

rcowham commented 1 week ago

It would be nice to be able to include

  - alert: InstanceDown
    expr: up == 0
    for: 5m
    labels:
      severity: page
    annotations:
      description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.'
      summary: 'Instance {{ $labels.instance }} down'

E.g. allow something like this:

      description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than {{ $for }}.'

Thoughts?

f41gh7 commented 1 week ago

Hello, it should be already possible to use the value of for field from alerting rule, in this case it should be 5m.

For the actual firing state of alert, it's recommended to use value of StartsAt field at alertmanager

https://prometheus.io/docs/alerting/latest/notifications/#alert

rcowham commented 1 day ago

Apologies - but at the link you gave I am not seeing "for" as an option. Should I raise it with prometheus guys?