Interview Prep/Monitoring & Observability/Grafana dashboards and data sources

Grafana data source test fails with `Bad Gateway` (HTTP 502)

BeginnerTroubleshootingGrafana dashboards and data sources
Answer

Likely causes → Grafana's backend cannot reach the URL: wrong host/port, DNS failure from the Grafana pod, NetworkPolicy, or the backend is down.

Diagnose →

kubectl exec -n monitoring deploy/grafana -- wget -qO- -T 5 http://prometheus-operated:9090/-/ready
kubectl logs -n monitoring deploy/grafana | grep -i 'proxy\|datasource'

Fix → Use the in-cluster DNS name (http://prometheus-operated.monitoring.svc:9090), set access mode to Server (not Browser), and open NetworkPolicy egress.

Prevent → Provision data sources as code and check them after cluster changes.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Grafana dashboards and data sources