This stack provides monitoring and visualization for Kubernetes-related metrics.
Prometheus collects and stores metrics, while Grafana reads from Prometheus and renders dashboards.
flowchart LR
K8s([Kubernetes]) -->|metrics| Prometheus[Prometheus :9090]
Prometheus --> Data[(Time-Series DB)]
Grafana[Grafana :3000] --> Prometheus
User([User]) --> Grafana
- Prometheus scrapes metrics targets configured in
prometheus/prometheus.yml. - Metrics are stored in Prometheus time-series storage.
- Grafana connects to Prometheus as a datasource.
- You explore metrics through Grafana dashboards and queries.
- Prometheus image:
prom/prometheus:latest - Grafana image:
grafana/grafana:latest - Prometheus UI:
http://<host-ip>:9090 - Grafana UI:
http://<host-ip>:3000 - Persistent data:
prometheus_data:/prometheusgrafana_data:/var/lib/grafana
- Mounted config/files:
./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml./token.txt:/etc/prometheus/token.txt:ro
Set via .env (copy from .env.example):
GF_SECURITY_ADMIN_USER(default:admin)GF_SECURITY_ADMIN_PASSWORD(default:admin)GF_USERS_ALLOW_SIGN_UP(default:false)
From the repository root:
cd grafana-prometheus-kubenetes
cp .env.example .env
docker compose up -dOpen:
- Prometheus:
http://localhost:9090 - Grafana:
http://localhost:3000
Use the Grafana admin credentials from your .env.
Useful commands:
docker compose ps
docker compose logs -f
docker compose restart
docker compose down- Validate scrape targets in Prometheus (
Status -> Targets). - Add/import Grafana dashboards for Kubernetes components.
- Keep
token.txtsecure because it may contain cluster access credentials.
- Ensure
prometheus/prometheus.ymlhas reachable targets from this Docker host. - Change default Grafana password before exposing the stack externally.