Interview Prep/Monitoring & Observability/Prometheus scraping and targets

Target shows `server returned HTTP status 403 Forbidden` when scraping kubelet / cAdvisor

IntermediateTroubleshootingPrometheus scraping and targets
Answer

Likely causes → The Prometheus ServiceAccount lacks RBAC for nodes/metrics or nodes/proxy, or the kubelet has webhook authorization on and the token is not bound.

Diagnose →

kubectl auth can-i get nodes/metrics --as=system:serviceaccount:monitoring:prometheus-k8s
kubectl auth can-i get nodes/proxy  --as=system:serviceaccount:monitoring:prometheus-k8s

Fix → Grant a ClusterRole with nodes, nodes/metrics, services, endpoints, pods (get/list/watch) and nonResourceURLs: ["/metrics"], bound to the SA. Use bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token.

Prevent → Install via kube-prometheus-stack, which ships correct RBAC, and test with kubectl auth can-i in CI.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus scraping and targets