A production-ready monitoring stack built on Kubernetes using Prometheus, Grafana, and Node Exporter. This setup also includes a custom application deployed from Docker Hub, so you can monitor real metrics from day one.
β Deploy Prometheus to scrape metrics β Node Exporter for system-level metrics β Grafana with beautiful dashboards β Custom App deployed from Docker Hub β Easy to extend for real-world projects
manifests/
βββ app-deployment.yaml # Deploys the sample application (from Docker Hub)
βββ grafana-deployment.yaml # Deploys Grafana into Kubernetes
βββ node-exporter-daemonset.yaml # Deploys Node Exporter as a DaemonSet on all nodes
βββ prometheus-configmap.yaml # Prometheus configuration (scrape targets, jobs, etc.)
βββ prometheus-deployment.yaml # Deploys Prometheus into Kubernetes
git clone https://github.com/<your-username>/Kubernetes-Monitoring-Stack-with-Prometheus-Grafana.git
cd k8s-prometheus-grafana/manifestskubectl apply -f .This will spin up Prometheus, Grafana, Node Exporter, and your app.
- Prometheus β http://localhost:9090
- Go to Status β Target Health to view the connected services' health status.
- Open Grafana http://localhost:3000 β Configuration β Data Sources β Add data source
- Select Prometheus
- Enter Prometheus URL:
http://prometheus:9090 - Click Save & Test β Should show Data source is working
If you want to check the raw metrics manually:
kubectl port-forward svc/node-exporter 9100:9100Now open β http://localhost:9100/metrics
π Youβll see plain text metrics like node_cpu_seconds_total, node_memory_MemAvailable_bytes, etc.
Grafana has prebuilt dashboards for Node Exporter:
- On dashboard left menu β Create β Import
- Option 1: Dashboard ID β enter
1860(Node Exporter Full) - Option 2: Upload JSON β you can download JSON from Grafana Dashboards
- Click Load β select your Prometheus data source β Import
Your Grafana dashboard will show:
- CPU usage (
node_cpu_seconds_total) - Memory usage (
node_memory_*) - Disk usage (
node_filesystem_*) - Network traffic (
node_network_*)
You can hover, zoom in/out, and set refresh intervals (e.g., 5s, 10s).
-
Click + β Dashboard β Add new panel
-
Select Prometheus as data source
-
Enter a metric query, e.g.:
node_cpu_seconds_total{mode="idle"} -
Choose visualization type: graph, gauge, table, etc.
-
Click Apply
Here are some useful queries to get started π
From your Flask app, you expose these Prometheus metrics:
http_requests_total{method, endpoint, http_status}β counterhttp_request_duration_seconds{endpoint}β histogramrandom_valueβ gaugeusers_signed_up_totalβ counterbackground_tasks_totalβ counter
rate(http_requests_total[1m])
π Shows how many requests per second are being handled, grouped by method, endpoint, and status code. Useful for a traffic dashboard β simulate load when refreshing tabs.
sum by (endpoint) (rate(http_requests_total[1m]))
π Compares which endpoints (/, /signup, /healthz) are hit most often.
Useful to see popular features in the app.
histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, endpoint))
π Shows 95th percentile latency per endpoint.
Replace 0.95 with 0.5 for median, 0.99 for tail latency.
increase(users_signed_up_total[5m])
π Number of new signups in the last 5 minutes. Useful to see effect of clicking "Get Started" button.
users_signed_up_total
π Shows the total counter value of signups so far.
rate(background_tasks_total[1m])
π Shows how often background jobs are firing (you have one every 5 seconds).
random_value
π Current gauge value (updates every 5 seconds). Great for live gauge panels in Grafana.
- Open
/and/dashboardin 3β5 browser tabs - Each refresh generates
http_requests_totalmetrics
- Click βGet Startedβ button multiple times
- This increments
users_signed_up_total - Grafana graph of
increase(users_signed_up_total[5m])will spike
- No action required β every 5 seconds,
background_tasks_totalandrandom_valueupdate automatically
while true; do curl -s http://<your-service-ip>:5000/ > /dev/null; doneπ rate(http_requests_total[1m]) will spike in Grafana
- In Grafana dashboard, set Refresh Interval = 5s
- Open multiple charts (requests/sec, latency, signups, gauge)
- Watch them update live as you interact with the app
Your app is deployed via app-deployment.yaml pulling directly from Docker Hub.
Update the image field if you want to replace it with your own app:
containers:
- name: demo-app
image: <your-dockerhub-username>/<your-app>:latest
ports:
- containerPort: 5000π License This project is open-source any one can use my project.