Blackbox: print several metrics in mail notification (example probe_http_status_code)

60 views
Skip to first unread message

Jason

unread,
Sep 25, 2023, 1:36:40 PM9/25/23
to Prometheus Users
Hi dear Community

I wish to output the metrics of blackbox_exporter

- probe_failed_due_to_regex
- probe_http_status_code

in alert mail

At the moment I do this, but it's not working


- alert: Blackbox-Probe-Result
expr: probe_success{app="ZZY", env="Prod", customer="OOO"} != 1
for: 1m
labels:
severity: warning
annotations:
summary: PPP
description: HTTP probe of {{ $labels.instance }} failed.
Regex Matching "probe_failed_due_to_regex" is {{
$labels.probe_failed_due_to_regex }} and the HTTP status code is {{
$labels.probe_http_status_code }}.


I found with a web
searchhttps://stackoverflow.com/questions/57022903/blackbox-exporter-alert-with-value-of-the-probe-http-status-code-metric

I did not understand it, why needed.

Any ideas?

Kind regards
Jason
OpenPGP_0x0D0C34B5DF58FE9D.asc
OpenPGP_signature.asc

Алексей Марковский

unread,
Sep 27, 2023, 3:53:16 AM9/27/23
to Prometheus Users
This is not how labels in templating work.

Syntax {{ $labels.probe_http_status_code }} supposed to include label probe_http_status_code from your alert.

You can include results of other queries with pattern like {{ printf " probe_http_status_code { app ='%s',  env ='%s', customer ='%s' }" .Labels. app  .Labels. env  .Labels. customer | query | first | value }}
 
понедельник, 25 сентября 2023 г. в 20:36:40 UTC+3, Jason:
Reply all
Reply to author
Forward
0 new messages