Kubernetes Monitoring
Build a mental model for observing cluster health with metrics-server, Prometheus, Grafana, logging stacks, and alerting components.
Why Monitoring Matters in Kubernetes
Kubernetes is dynamic. Pods move, restart, scale, and disappear. Without monitoring, debugging becomes guesswork.
First Layer: Basic Resource Metrics
The simplest built-in style of monitoring is resource usage via metrics-server.
kubectl top nodes
kubectl top pods
These commands help you spot overloaded nodes or unexpectedly heavy pods.
Common Monitoring Stack Components
| Component | Purpose |
|---|---|
| metrics-server | Lightweight CPU and memory metrics for kubectl top and HPA |
| Prometheus | Time-series metrics collection and querying |
| Grafana | Dashboards and visualization |
| kube-state-metrics | Exposes Kubernetes object state as metrics |
| node-exporter | Host-level node metrics |
| Alertmanager | Routes and groups alerts |
Prometheus Scraping Flow
Prometheus observability stack
Metric sources (expose /metrics endpoint)
App Pods
custom metrics
node-exporter
host metrics
kube-state-metrics
K8s object state
kubelet
cAdvisor metrics
Prometheus
Scrapes, stores, and queries metrics (PromQL)
Grafana
Dashboards & visualisation
Alertmanager
Routes alerts → Slack / PagerDuty
ServiceMonitor Mention
In Prometheus Operator-based setups, a ServiceMonitor custom resource often tells Prometheus which Services to scrape.
Logging in Kubernetes
Metrics are only part of observability. For logs, teams often use stacks based on:
- Fluentd or Fluent Bit
- Loki
- ELK or OpenSearch-based pipelines
Tracing Mention
For distributed tracing across microservices, tools such as Jaeger or Tempo can help show request paths and latency between services.
Why Layered Observability Wins
- metrics tell you something is wrong
- logs help explain what happened
- traces show how requests moved through services
Monitoring is like the dashboard of a plane. You do not want only one gauge. You want fuel, altitude, speed, warnings, and route visibility together.
kubectl Top Dependency
What component commonly powers `kubectl top pods` and `kubectl top nodes`?
Observability Layers
Which statement best describes logs, metrics, and traces together?