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.
More on Prometheus scraping and targets
A target shows `DOWN` on `/targets` with `Get "http://10.0.3.14:9100/metrics": context deadline exceeded`BeginnerTarget shows `server returned HTTP status 403 Forbidden` when scraping kubelet / cAdvisorIntermediateTarget is `DOWN` with `connect: connection refused`BeginnerTarget shows `x509: certificate signed by unknown authority`IntermediateTarget shows `x509: certificate is valid for app.svc, not 10.0.4.22`IntermediateA target is `UP` but `/targets` shows `expected a valid start token, got "<" ("INVALID") while parsing: "<"`Intermediate