From 0dc9009fd4fa2400fb1f51f359eb8ca235184bb7 Mon Sep 17 00:00:00 2001 From: Max Lemieux Date: Wed, 1 Jan 2025 17:01:16 -0500 Subject: [PATCH 1/2] Update prometheus.exporter.blackbox.md Added an example of how to configure the `instance` label to work better with some prebuilt dashboards that expect the target url here. --- .../prometheus.exporter.blackbox.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md b/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md index 5eba120e5c..b604620084 100644 --- a/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md +++ b/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md @@ -259,6 +259,37 @@ Replace the following: [disc]: ../discovery.file/ [relabel]: ../discovery.relabel/ +### Set instance label to target url + +Some dashboards may expect the `instance` label on the Blackbox metrics to contain the value of the target url. Here's how to achieve that with Prometheus relabeling: + +```alloy +prometheus.exporter.blackbox "example" { + config = "{ modules: { http_2xx: { prober: http, timeout: 5s } } }" + + target { + name = "example" + address = "example.com" + module = "http_2xx" + } +} + +discovery.relabel "example" { + targets = prometheus.exporter.blackbox.example.targets + + rule { + source_labels = ["__param_target"] + target_label = "instance" + } +} + +prometheus.scrape "example" { + targets = discovery.relabel.example.output + forward_to = [prometheus.remote_write.metrics_service.receiver] +} + +``` + ## Compatible components From 62c564a07ec6006b91e0eafbe1ded274624a74cf Mon Sep 17 00:00:00 2001 From: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com> Date: Tue, 28 Jan 2025 10:16:26 -0800 Subject: [PATCH 2/2] Update docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md --- .../components/prometheus/prometheus.exporter.blackbox.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md b/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md index b604620084..a2c65fedcb 100644 --- a/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md +++ b/docs/sources/reference/components/prometheus/prometheus.exporter.blackbox.md @@ -261,7 +261,8 @@ Replace the following: ### Set instance label to target url -Some dashboards may expect the `instance` label on the Blackbox metrics to contain the value of the target url. Here's how to achieve that with Prometheus relabeling: +Some dashboards may expect the `instance` label on the Blackbox metrics to contain the value of the target URL. +The following example demonstrates how to achieve that with Prometheus relabeling: ```alloy prometheus.exporter.blackbox "example" {