Interview Prep/Monitoring & Observability/Prometheus scraping and targets

Target is `DOWN` with `server returned HTTP status 401 Unauthorized`

BeginnerTroubleshootingPrometheus scraping and targets
Answer

Likely causes → The endpoint needs auth and the scrape config has none, the token/password rotated, or the wrong Secret is mounted.

Diagnose →

curl -i http://app:8080/metrics                     # 401 confirms auth required
curl -i -H "Authorization: Bearer $TOKEN" http://app:8080/metrics

Fix → Add credentials to the job:

- job_name: app
  authorization:
    type: Bearer
    credentials_file: /etc/prometheus/secrets/app-token
  # or basic_auth: { username: prom, password_file: /etc/prometheus/secrets/pw }

Use *_file fields so rotation does not need a config edit, then reload.

Prevent → Alert on up == 0 per job; keep scrape creds in a secret manager with rotation hooks.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus scraping and targets