ansible-infra/chris-here-bitte/templates/alloy/blackbox-exporter.alloy
lilly 4a7df9969d
Some checks failed
/ Ansible Lint (push) Failing after 2m17s
tmp
2026-02-26 21:13:10 +01:00

102 lines
2.4 KiB
Text

// {{ ansible_managed }}
// For a full configuration reference, see https://grafana.com/docs/alloy
discovery.http "netbox_devices" {
url = "{{ alloy_netbox_uri | mandatory }}/api/plugins/prometheus-sd/devices/"
http_headers = {
"Authorization" = [ "Token {{ alloy_netbox_api_key | mandatory }}" ],
}
}
// ICMP probe definitions
discovery.relabel "icmp_probes_netbox" {
targets = discovery.http.netbox_devices.targets
// drop devices which don't have an IP address
rule {
source_labels = [ "__meta_netbox_primary_ip4" ]
regex = ".+"
action = "keep"
}
// configure target metadata from discovery
rule {
source_labels = [ "__meta_netbox_primary_ip4" ]
target_label = "address"
}
rule {
source_labels = [ "__meta_netbox_name" ]
target_label = "name"
}
rule {
source_labels = [ "__meta_netbox_location" ]
target_label = "location"
}
rule {
source_labels = [ "__meta_netbox_role" ]
target_label = "netbox_role"
}
rule {
source_labels = [ "__meta_netbox_status" ]
target_label = "netbox_status"
}
// set probe module to icmp4 to execute pings via ipv4
rule {
target_label = "module"
replacement = "icmp4"
}
}
discovery.file "icmp_probes" {
files = [ "/etc/alloy/icmp_probes.json" ]
}
prometheus.exporter.blackbox "icmp" {
config_file = "/etc/alloy/blackbox-exporter-config.yaml"
targets = discovery.file.icmp_probes.targets
}
// HTTPS probe definitions
prometheus.exporter.blackbox "web" {
config_file = "/etc/alloy/blackbox-exporter-config.yaml"
target {
name = "eurofurence.org"
address = "https://www.eurofurence.org/EF29/"
module = "https4_2xx"
labels = { probed_instance = "eurofurence.org" }
}
}
// scraping config
discovery.relabel "blackbox_probes" {
targets = array.concat(
prometheus.exporter.blackbox.icmp.targets,
prometheus.exporter.blackbox.web.targets,
)
// add "probe_module" label based on which probe module was used
rule {
source_labels = [ "__param_module" ]
target_label = "probe_module"
}
// add "probe_target" label based on what was probed
rule {
source_labels = [ "__param_target" ]
target_label = "probe_target"
}
}
prometheus.scrape "blackbox_probes" {
targets = discovery.relabel.blackbox_probes.output
forward_to = [ prometheus.remote_write.ef_mimir.receiver ]
scrape_interval = "30s"
scrape_timeout = "30s"
}