Hi Julius, 

Thanks for your prompt response. 

{{ with query "time()" }}{{ . | first | value }}{{ end}}

This expression is exactly what I need. 
And I wanna learn how to assemble such an expression. After searching 
through this document template <https://golang.org/pkg/text/template/> , 
still no clue about these in the expression you wrote: query, first, value. 
Could you give me an advice?




在 2020年5月20日星期三 UTC+8下午3:12:51,Julius Volz写道:
>
> Not sure what exactly your use case is, but if you just want the current 
> (at the time of alert evaluation) Unix timestamp in an annotation, you 
> should be able to do:
>
> {{ with query "time()" }}{{ . | first | value }}{{ end}}
>
> Note that the "Alert" struct on the Alertmanager templating side will also 
> have timestamp fields on it that tell you when an alert first started 
> firing, and when it will expire if it's no longer sent from Prometheus:
>
> https://prometheus.io/docs/alerting/notifications/#alert
>
>
>
> On Wed, May 20, 2020 at 5:59 AM zichen chuh <ziche...@gmail.com 
> <javascript:>> wrote:
>
>> I went through documents given by prometheus website and didn't find a 
>> clue.
>>
>> From alerting_rules 
>> <https://prometheus.io/docs/prometheus/latest/configuration/alerting_rules/#templating>
>>  , 
>> only 3 variables are available : $lables, $externalLabels, $value.
>>
>> Thanks in advance.
>>
>> -- 
>> 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 promethe...@googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/prometheus-users/d5b9244a-1582-4816-a314-9b7c9917aa10%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/prometheus-users/d5b9244a-1582-4816-a314-9b7c9917aa10%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 prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/75ba9eed-10f2-467f-bada-22be090ef45a%40googlegroups.com.

Reply via email to