Interview Prep/Monitoring & Observability/Prometheus scraping and targets

A target is `UP` but `/targets` shows `expected a valid start token, got "<" ("INVALID") while parsing: "<"`

IntermediateTroubleshootingPrometheus scraping and targets
Answer

Likely causes → The path returns HTML (login page, 404 page, SPA index) instead of exposition format. Usually wrong metrics_path or an auth proxy redirect.

Diagnose →

curl -sL http://app:8080/metrics | head -5
curl -sI http://app:8080/metrics      # look for 302 to /login

Fix → Point metrics_path at the real endpoint (/actuator/prometheus for Spring Boot, /metrics for most others), or exempt it from the auth proxy.

Prevent → Add a smoke test that runs promtool check metrics against the endpoint in CI.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus scraping and targets