Case Study: Prometheus & Actuator Observability Cloaking
This case study demonstrates how to protect internal telemetry, metrics scrapers, and diagnostic dumps from public disclosure while preserving uninterrupted collection by internal monitoring pipelines (Prometheus, Datadog, SIEM collectors).
The Threat Model
Most modern microservices expose operational metrics and health dashboards out-of-the-box:
- Prometheus Scrape Endpoints:
/metrics - Spring Boot Actuator:
/actuator,/actuator/env,/actuator/heapdump,/actuator/loggers - Go Runtime Profiling:
/debug/pprof,/debug/vars
When exposed to the public internet, these endpoints leak proprietary architecture details, server environment variables, memory layouts, and query patterns to competitive reconnaissance bots and exploit kits.
The Solution: Two-Tier Masking with Healthcheck Allowlisting
Routewarden enforces a granular defense policy:
- Public Healthcheck Allowlist (
allowPatterns): Safe liveness probes (e.g./actuator/health,/healthz) remain reachable by external load balancers and uptime monitors. - Sensitive Observability Cloaking (
blockPatterns): All other telemetry endpoints (/metrics,/actuator/env,/debug/pprof) are intercepted at the edge and cloaked with404 Not Found. - Authorized Scrapers (
allowedIps): Monitoring servers (Prometheus, Datadog) originating from trusted VPC subnets or Kubernetes pod CIDRs bypass the block and scrape full metrics uninterrupted.
Configuration (Traefik, Caddy & NGINX)
# dynamic_conf.ymlhttp: middlewares: metrics-cloak: plugin: routewarden: enabled: true methods: - GET - POST - PUT - DELETE - PATCH - HEAD enableDefaultPatterns: true # Allow safe public healthcheck probe allowPatterns: - '(?i)^/actuator/health$' - '(?i)^/healthz$' # Guard all other metrics, profiling, and actuator endpoints blockPatterns: - '(?i)^/(metrics|server-metrics|telemetry)(/.*)?$' - '(?i)^/actuator(/.*)?$' - '(?i)^/debug/(pprof|vars)(/.*)?$' # Allow internal Prometheus scraper & Kubernetes VPC allowedIps: - "10.0.0.50/32" # Dedicated Prometheus server IP - "10.244.0.0/16" # Internal Kubernetes Pod Network - "127.0.0.1" # Localhost diagnostic agent response: mode: json statusCode: 404 body: '{"error":"Not Found","message":"The requested URL was not found on this server"}' routers: app-router: rule: "Host(`app.example.com`)" entryPoints: - websecure middlewares: - metrics-cloak service: app-service