Query condition in alert template

11 views
Skip to first unread message

fiala...@gmail.com

unread,
Mar 18, 2021, 6:00:22 AM3/18/21
to Prometheus Users
Hi,

I have the description for port utilization alert defined this way:

Interface Problem: Utilization OUT [[ $value ]]% (current: [[ printf "round(port_out_bps{port_id='%s'} / ignoring(job) port_speed{port_id='%s'} * 100, 0.1)" .Labels.port_id .Labels.port_id | query | first | value ]]%)

Sometimes when I have no data from metric port_out_bps I got this error as description of alert:

"<first>: error calling first: first() called on vector with no elements"

Is there a way, how to check in template returned value and set fallback value for current utilization to "unknown" ?

Thank you.



Reply all
Reply to author
Forward
0 new messages