Prometheus
Prometheus is an open-source monitoring system that collects time-series metrics by scraping HTTP endpoints at regular intervals, stores them locally, and exposes them through the PromQL query language. In Kubernetes it is the standard tool for pod, node, and application metrics.
The pull model
Instead of applications pushing metrics, Prometheus visits each target's /metrics endpoint on a schedule, commonly every 15 to 30 seconds. A failed scrape is itself a signal that the target is down. Short-lived jobs that cannot be scraped can use the Pushgateway.
Install the full stack
helm repo add prometheus-community https://prometheus-community.github.io/helm-chartshelm repo updatehelm install kube-prometheus-stack prometheus-community/kube-prometheus-stack \ --namespace monitoring --create-namespace \ --set prometheus.prometheusSpec.retention=30dkubectl port-forward svc/prometheus-operated 9090:9090 -n monitoringThe chart installs Prometheus, Alertmanager, Grafana, Node Exporter, and kube-state-metrics, managed by the Prometheus Operator.
Scrape your app with a ServiceMonitor
apiVersion: monitoring.coreos.com/v1kind: ServiceMonitormetadata: name: payment-api namespace: production labels: release: kube-prometheus-stack # must match the Prometheus selectorspec: selector: matchLabels: app: payment-api endpoints: - port: http path: /metrics interval: 15sCheck the Targets page at http://localhost:9090/targets. A target should show state UP.
Troubleshooting
| Problem | Likely cause | Fix |
|---|---|---|
| Target DOWN | App not exposing metrics | Curl /metrics from inside the pod |
| ServiceMonitor ignored | Label selector mismatch | Match the release label |
| High memory use | High-cardinality labels | Remove IDs from labels |
| Data lost | No persistent volume | Use persistent storage |
TipKeep label values low cardinality. A label such as
user_idcreates a time series per user and can exhaust memory.
RememberPrometheus stores data locally and is not horizontally scalable. For long retention or multiple clusters, add remote write to Thanos, Mimir, or a managed service.
Common MistakeTreating a single Prometheus as long-term storage. Set retention and size limits and plan remote storage for compliance needs.
Frequently Asked Questions
Why does Prometheus pull instead of receiving pushes?
Pulling makes target health visible, needs no ingestion pipeline for applications, and lets you scrape a target ad hoc while debugging. The Pushgateway covers short-lived batch jobs.
What is cardinality explosion?
Putting unbounded values such as user IDs or URLs into labels creates a huge number of series, which inflates memory and disk usage. Keep label values bounded.
What does kube-state-metrics add?
It exposes Kubernetes object state as metrics, such as desired and available replicas and pod phases, complementing resource usage metrics from cAdvisor and Node Exporter.