1. Deploying with kube-prometheus-stack #
The reference chart.
Installation #
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts && helm repo update
helm install monitoring prometheus-community/kube-prometheus-stack -n monitoring --create-namespace
kubectl -n monitoring get podsapiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata: { name: shop, namespace: shop, labels: { release: monitoring } }
spec:
selector: { matchLabels: { app: shop } }
endpoints: [ { port: metrics, interval: 30s } ]Common mistake: By default, the chart's Prometheus only selects ServiceMonitors carrying the chart's release label: without this label, your targets never appear.2. The Prometheus web interface #
The first diagnostic tool.
Useful pages #
kubectl -n monitoring port-forward svc/monitoring-kube-prometheus-prometheus 9090
# puis http://localhost:9090| Page | Usage |
|---|---|
| Query (Graph) | Test a PromQL query, as a table or a graph |
| Status > Targets | Scraped targets, UP/DOWN state and last error |
| Status > Service discovery | Discovered targets before and after relabeling |
| Alerts, Rules | Alerting and recording rules, pending or firing state |
| Status > TSDB | Cardinality: the most expensive metrics and labels |
Good practice: When a metric is missing in Grafana, first check Status > Targets in the Prometheus interface: the cause is almost always a DOWN or missing target.

