On 21 May 14:33, Frank R wrote:
> Alert templating question.
> 
> I have an issue where some targets have a hostname label. When there is no 
> hostname label the instance label should be used. 
> 
> Would this work in a prometheus alert annotation:
> 
> {{ or $labels.hostname $labels.instance }}

I am not going to answer your question because I am using another trick
to achieve this.

In the prometheus config:

alerting:
 alert_relabel_configs:
 - source_labels: [instance, hostname]
   regex: "(.+);"
   target_label: hostname
   replacement: '$1'

That way, prometheus will add a hostname label equal to the instance to
every alert if it is empty.

Regards,


> 
> ?
> 
> -- 
> 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/dc4da945-8fd1-41dc-9c10-ced090a1ca2d%40googlegroups.com.


-- 
Julien Pivotto
@roidelapluie

-- 
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/20200521213737.GB429560%40oxygen.

Reply via email to