Skip to content

Ingress & HTTPRoutes as Prometheus HTTP_SD Targets

Prometheus

Automating blackbox uptime monitoring for every service deployed in Kubernetes can become an operational burden.

Using httproute-prometheus-shim, you can automatically discover all Ingress and Gateway API HTTPRoute endpoints and expose them as a native Prometheus HTTP Service Discovery (http_sd_configs) target feed.


Architecture

graph LR
    K8s["Kubernetes API<br/>(Ingresses & HTTPRoutes)"] --> Shim["httproute-prometheus-shim Pod"]
    Shim -- "Exposes JSON on :9113/httproutes-sd" --> Prom["Prometheus (http_sd_configs)"]
    Prom --> Blackbox["Prometheus Blackbox Exporter (HTTP 2xx Probe)"]

Step 1. Install httproute-prometheus-shim

shim-values.yaml

httpRoute:
  enabled: false

helm install httproute-prometheus-shim oci://registry-1.docker.io/dennysv/httproute-prometheus-shim \
  --version 1.0.3 \
  --namespace monitoring \
  --create-namespace \
  -f shim-values.yaml

Step 2. Configure Prometheus Blackbox Scrape Job

In your kube-prometheus-stack values, add the HTTP_SD target:

additionalScrapeConfigs:
  - job_name: "blackbox-httproutes-autodiscovery"
    metrics_path: /probe
    params:
      module: [http_2xx]
    http_sd_configs:
      - url: "http://httproute-prometheus-shim.monitoring.svc.cluster.local:9113/httproutes-sd"
        refresh_interval: 1m
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - source_labels: [__param_target]
        regex: "(.+)"
        replacement: "https://$1"
        target_label: __param_target
      - target_label: __address__
        replacement: "prometheus-blackbox-exporter.monitoring.svc.cluster.local:9115"