Hi, 
As you have guessed I want to know the time when the alert first started 
firing. 
I simply tried adding the alerting rules as in example :


  - alert: InstanceDown
    expr: up == 0
    for: 5m
    labels:
      severity: critical
    annotations:
      timestamp: >
        time:  {{ .StartsAt }}

Which leaves me with the error:
= <error expanding template: error executing template __alert_InstanceDown: 
template: __alert_InstanceDown:1:90: executing "__alert_InstanceDown" at 
<.StartsAt>: can't evaluate field StartsAt in type struct { Labels 
map[string]string; ExternalLabels map[string]string; Value float64 }>

Regards,
Sebastian 



On Tuesday, May 3, 2022 at 9:47:25 PM UTC+2 [email protected] wrote:

> Hi Sebastian,
>
> What error are you getting and what's your config? The first answer puts 
> the current time of the evaluation of the alerting rule into the "time" 
> annotation (which wouldn't necessarily be the time the alert started 
> firing, but the last time it was still evaluated as firing). The second 
> Stack Overflow answer is maybe more what you want, accessing the 
> ".StartsAt" field of an alert directly from an Alertmanager notification 
> template, and thus telling you when the alert first started firing. If you 
> share what you already have (and which kind of timestamp you expect), maybe 
> we can help you make it work.
>
> Regards,
> Julius
>
> On Tue, May 3, 2022 at 11:49 AM Sebastian Osztovits <
> [email protected]> wrote:
>
>>
>> Hello, 
>> I'm currently using Alert manager 0.22.2 and Prometheus 2.18.1. 
>> I have tried to alter my alert as shown in stack overflow  post:  
>>
>>
>> https://stackoverflow.com/questions/41069912/populating-a-date-time-in-prometheus-alert-manager-e-mail
>> yet i am met with an error message when doing so. 
>> Does anyone have and email Template where they successfully added a 
>> Timestamp?
>> Thanks in advance. 
>> Best Regards, 
>> Sebastian 
>>
>> -- 
>> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/prometheus-users/e03a03be-4d88-4ded-b969-f36a06c469f2n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/prometheus-users/e03a03be-4d88-4ded-b969-f36a06c469f2n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
> Julius Volz
> PromLabs - promlabs.com
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/a2631779-dd7c-40fe-897e-7de27d8c7c0dn%40googlegroups.com.

Reply via email to