I’ve mostly managed to get scraping with Blackbox to work but I’m having issues normalizing the target FQDNs across my scrape configs. Here’s one of my scrape configs:
---
apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
name: &app exporter-blackbox
namespace: monitoring
spec:
scrapeInterval: 1m
metricsPath: /probe
params:
module: [http_2xx]
staticConfigs:
- targets:
- http://brother_hl-2270dw.internal.untouchedwagons.com
- http://homeassistant.internal.untouchedwagons.com:8123
- https://pve-cluster-node-01.internal.untouchedwagons.com:8006
relabelings:
- action: replace
sourceLabels: [__address__]
targetLabel: __param_target
- action: replace
sourceLabels: [__param_target]
targetLabel: instance
- action: replace
targetLabel: __address__
replacement: exporter-blackbox.monitoring.svc.cluster.local:9115
- action: replace
targetLabel: module
replacement: http_2xx
There are other targets of course but as you can see two are http while the third is https, the first has no port specified while the second and third do. My other scrape jobs are similar with other modules and ports. What I want is the FQDN to be the same across all the jobs (IE pve-cluster-node-01.internal.untouchedwagons.com
). I’ve tried using a regex to strip the protocol and optional port but I get alerts from Prometheus that these scrap jobs have been rejected.
relabelings:
- action: replace
sourceLabels: [__address__]
targetLabel: __param_target
- action: replace
sourceLabels: [__param_target]
regex: ([\w\-.]+):?+[\d]* # This does not work
replacement: '$1' # This does not work
targetLabel: instance
- action: replace
targetLabel: __address__
replacement: exporter-blackbox.monitoring.svc.cluster.local:9115
- action: replace
targetLabel: module
replacement: ssh_banner