In a production environment you would typically deploy Prometheus via the Prometheus Operator or Helm charts. This lesson uses basic manifests so you can see the configuration files Prometheus and Grafana rely on.
- Create a dedicated monitoring namespace
- Inspect Prometheus configuration and create a ConfigMap
- Deploy Prometheus (Deployment + Service + RBAC)
- Explore Prometheus targets and key metrics
- Deploy Grafana and add Prometheus as a data source
- Visualize Prometheus metrics in Grafana
1) Create a monitoring namespace
Create a separate namespace to keep monitoring resources (Prometheus, Grafana) isolated from application and control-plane objects. Verify existing namespaces:monitoring namespace:
2) Inspect Prometheus manifests
List the Prometheus manifest directory to see what files are available:
Open
prometheus.yml to inspect global settings (scrape/evaluation intervals) and scrape_configs (jobs and discovery). Example:
scrape_configs?
Answer: prometheus and kubernetes-nodes.
Create a ConfigMap from prometheus.yml
Create a ConfigMap named prometheus-config in the monitoring namespace from the file:
3) Deploy Prometheus
Inspectprometheus-deployment.yaml — it contains:
- Deployment running the Prometheus container (args point to the config file and storage path)
- A
ConfigMapvolume mounted at/etc/prometheus - A ClusterIP Service exposing Prometheus internally at port 9090
- ServiceAccount, ClusterRole, and ClusterRoleBinding for Kubernetes discovery
prometheus-deployment.yaml:
4) Inspect Prometheus targets and metrics
Open the Prometheus UI (port-forward or NodePort) and go to Status → Targets. This page shows endpoints Prometheus is scraping based onscrape_configs from the loaded ConfigMap.
Typical Targets examples:
- Prometheus scrape target:
instance="localhost:9090" job="prometheus"
- Node exporter (kubernetes-nodes) target (example error):
instance="controlplane" job="kubernetes-nodes"
Error:
Get “http://192.168.228.25:9100/metrics”: dial tcp 192.168.228.25:9100: connect: connection refused
Prometheus also exposes builtin metrics. The up metric is the simplest health indicator:
up= 1 → target scraped successfullyup= 0 → target unreachable / scrape failed
up):
prometheus_http_requests_total (HTTP handler request totals), helpful for inspecting Prometheus’ own behavior:
Example series:
5) Deploy Grafana
Inspectgrafana/grafana-deployment.yaml. The Deployment runs Grafana on port 3000; for this lesson the admin password is set by environment variables (lab/demo purpose only).
Key parts of the Grafana manifest:
- Username:
admin - Password:
admin
For lab/demo purposes the admin password is set via an environment variable and uses the default
admin password. Do NOT use default or insecure credentials in production — rotate credentials and use secure secrets management.6) Add Prometheus as a Grafana data source
Open Grafana and navigate to Connections → Data sources → Add data source.

localhost?
- Grafana and Prometheus run in different pods;
localhostwithin the Grafana pod would point to Grafana itself. Use the Kubernetes Service DNS (prometheus.monitoring.svc.cluster.local:9090) to reach another in-cluster service.
7) Explore Prometheus metrics in Grafana
Open Grafana’s Explore view, select Prometheus as the data source, and run queries such as:upprometheus_http_requests_total
- Richer visualizations and charting options
- Ability to combine multiple queries
- Smoother rendering and history navigation
- Dashboard sharing and alerting integrations
prometheus_http_requests_total to see series split by labels like code, handler, instance, and job.
Recap
- Created a dedicated
monitoringnamespace. - Loaded Prometheus configuration into a ConfigMap and deployed Prometheus (Deployment + Service + RBAC).
- Inspected Prometheus targets and used
upand internal metrics such asprometheus_http_requests_total. - Deployed Grafana and added Prometheus as a data source using the in-cluster Service DNS.
- Visualized Prometheus metrics from Grafana’s Explore view.
Links and references
- Prometheus documentation: https://prometheus.io/docs/
- Grafana documentation: https://grafana.com/docs/
- Kubernetes documentation: https://kubernetes.io/docs/