Skip to main content
Grafana visualizes time-series data but does not store metrics itself. To display metrics, Grafana needs a data source that points to a metrics backend such as Prometheus. This guide shows how to connect Grafana to an in-cluster Prometheus instance (kube-prometheus-stack) running in the monitoring namespace. Environment: kube-prometheus-stack is installed in the monitoring namespace. Verify the Prometheus and Grafana pods and services with kubectl.
From the service listing you can quickly identify where to point Grafana: For background on in-cluster DNS resolution and service names, see the Kubernetes DNS docs: https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/ Next, open Grafana and add Prometheus as a data source. Click “Add your first data source” (or Add data source) and choose Prometheus from the list:
A screenshot of Grafana's "Add data source" interface in dark mode. It shows a list of time-series and logging/database options including Prometheus, Graphite, InfluxDB, OpenTSDB, Loki, and Elasticsearch.
On the Prometheus data source configuration page:
  • Leave Name as the default (Prometheus) unless you need multiple Prometheus endpoints.
  • Set the URL to point to your Prometheus service inside the cluster. When Grafana runs inside the same cluster, use the in-cluster DNS name in this form:
This matches the Kubernetes service DNS pattern: service-name.namespace.svc.cluster.local:port.
If Grafana runs inside the same Kubernetes cluster, the in-cluster DNS name (prometheus-operated.monitoring.svc.cluster.local:9090) will resolve automatically. If Grafana runs outside the cluster, point the URL to an external address such as the NodePort (e.g., http://<NODE_IP>:30090) or an Ingress endpoint instead.
Optionally enable the “Default” toggle to make this Prometheus instance the default for new dashboards. Leave other settings at their defaults unless you have specific proxy, authentication, or TLS needs. Click Save & test. If the connection succeeds, Grafana will confirm it can query the Prometheus API with a success banner:
A screenshot of Grafana’s Connections > Data sources > Prometheus settings page showing performance and query options (e.g., cache level, HTTP method set to POST, series limit 40000). A green banner at the bottom indicates "Successfully queried the Prometheus API," with Delete and Save & test buttons visible.
Troubleshooting checklist (if Save & test fails):
  • Ensure the URL includes the scheme (http://) and correct service name, namespace and port.
  • Confirm Prometheus is running: kubectl get pods -n monitoring.
  • Verify Grafana’s network access:
    • If Grafana is in-cluster, ensure it can resolve the in-cluster DNS name (test with a busybox or curl pod).
    • If Grafana is external, test connectivity to the NodePort or Ingress (curl http://<NODE_IP>:30090/api/v1/status/flags).
  • Check Prometheus logs for errors: kubectl logs -n monitoring prometheus-kube-prometheus-stack-prometheus-0.
Avoid exposing Prometheus or Grafana publicly without authentication or network restrictions. If you use NodePorts or Ingress, add proper access controls (Ingress auth, network policies, or firewall rules).
What’s next

Watch Video