Open ashi009 opened 1 year ago
Can you provide a use case? I fail to see where they would be useful in a notification template.
For our case, we have an alert for cert expiry, eg.
- alert: CertificateNearExpiry
expr: certificate_expiry_time - time() < 7 * 60*60*24
annotations:
expiry_time: ' {{ printf "certificate_expiry_time{sn=%q}" $labels.sn | query | first | value }}'
expiry_time_humanreadable: ' {{ printf "certificate_expiry_time{sn=%q}" $labels.sn | query | first | value | humanizeTimestamp}}'
value: !unsafe "{{ $value }}"
value_humanreadable: !unsafe "{{ $value | humanizeDuration }}"
When this alert is routed to alertmanager, we have it delivered to both webhook and an email receiver. The former will take advantage of the raw value (for triggering automations), while the latter will use the humanreadable value for the template.
_humanreable
annotations are only required because those number functions are not available in alertmanager world.
alright this sounds like a niche but legit addition.
https://prometheus.io/docs/prometheus/latest/configuration/template_reference/#numbers are stateless, and pure functions, they could come in handy in alertmanager.