Prompt
How do I get better visibility into Kubernetes cluster health?
Latest observation
To get better visibility into Kubernetes cluster health, aim for three layers of observability:
- Metrics — what is happening
- Logs — why it happened
- Traces/events — where it happened and how it propagates
Here’s a practical approach.
1) Start with the key cluster metrics
Monitor both cluster-level and workload-level health.
Cluster-level metrics
Track:
- Node status: Ready/NotReady, pressure conditions
- Pod status: Pending, CrashLoopBackOff, OOMKilled, restarts
- CPU / memory / disk / network usage
- API server latency and error rates
- etcd health: latency, leader changes, DB size
- Scheduler and controller manager health
- Kubelet health
- Persistent volume and storage health
Workload-level metrics
Track:
- Request rate
- Error rate
- Latency
- Saturation (CPU/memory throttling, queue depth)
- HPA behavior and scaling events
A useful rule: if you can only watch a few things, start with:
- Node readiness
- Pod restart rate
- CPU/memory requests vs usage
- API server latency/errors
- etcd health
2) Use Prometheus + Grafana for metrics
This is the standard stack for Kubernetes observability.
What to deploy
- Prometheus for scraping metrics
- Grafana for dashboards
- kube-state-metrics for Kubernetes object state
- node-exporter for node OS metrics
- Optional: cAdvisor / kubelet metrics for container resource usage
Good dashboards
Create dashboards for:
- Cluster overview
- Node health
- Namespace/workload health
- Control plane health
- Persistent volumes/storage
- Network and ingress health
If you use the kube-prometheus-stack Helm chart, you get a strong baseline quickly.
3) Add alerts that reflect user impact
Health visibility improves a lot when alerts are tied to symptoms, not just raw resource use.
Good alerts
- Node NotReady for > 5 minutes
- Pod crash loops or repeated restarts
- Deployment unavailable replicas > 0
- CPU throttling sustained
- Memory pressure on nodes
- Disk pressure / ephemeral storage exhaustion
- API server elevated 5xx or latency
- etcd high latency or unavailable
- HPA unable to scale or hitting max replicas
- PVs nearly full or mount failures
Avoid noisy alerts
Don’t alert only on:
- CPU > 80% by itself
- Memory > 80% by itself
Those are useful as warnings, but better when combined with saturation, latency, or failures.
4) Centralize logs
Metrics tell you something is wrong; logs explain why.
Recommended logging setup
- Collect container logs from all nodes
- Use a central log backend:
- Loki + Grafana
- ELK / OpenSearch
- Cloud logging services like CloudWatch, Stackdriver/Cloud Logging, Azure Monitor
Log best practices
- Use structured JSON logs
- Include:
- request ID / trace ID
- namespace, pod, container
- severity level
- error code/message
- Avoid excessive logging volume from debug logs in production
5) Enable events visibility
Kubernetes events are very useful for cluster health.
Watch for events like:
- Failed scheduling
- Image pull errors
- CrashLoopBackOff
- Readiness/liveness probe failures
- PVC mount problems
- Node pressure eviction
- Preemption
- Autoscaling actions
You can inspect them with:
kubectl get events -A --sort-by=.metadata.creationTimestamp
For better retention/search, export events to your logging or observability platform.
6) Use health checks properly
Make sure workloads expose:
- liveness probes: restart unhealthy containers
- readiness probes: remove unhealthy pods from service endpoints
- startup probes: allow slow-starting apps enough time
This improves visibility because failing probes show up as clear signals.
7) Observe the control plane
A lot of cluster health issues come from the control plane, not just workloads.
Watch:
- API server request latency
- API server 4xx/5xx rates
- etcd disk and latency
- controller reconciliation delays
- scheduler queue depth / scheduling latency
If you run your own control plane, make sure those components are exported into Prometheus and dashboarded.
8) Add synthetic checks and SLOs
Health isn’t just “is the cluster up?” but “can users successfully use it?”
Synthetic checks
Run periodic checks for:
- Can the app endpoint be reached?
- Can a test pod be scheduled?
- Can a ConfigMap/Secret be mounted?
- Can a PVC be provisioned?
SLOs
Define service-level objectives like:
- 99.9% successful requests
- p95 latency under X ms
- Pod availability above Y%
Then alert on error-budget burn, not just infrastructure symptoms.
9) Use managed-platform tools if available
If you’re on a cloud managed service:
- EKS: CloudWatch Container Insights, Managed Prometheus
- GKE: Cloud Monitoring / Logging, Managed Prometheus
- AKS: Azure Monitor Container Insights
These can provide quicker time-to-value, especially for control plane visibility.
10) Create a “cluster health” dashboard
A good single-pane dashboard should show:
- Node count and NotReady nodes
- Pod phase breakdown
- Restart counts
- CPU/memory usage vs requests/limits
- Disk pressure / filesystem usage
- API server latency/errors
- etcd health
- Top failing namespaces/deployments
- Pending pods and scheduling failures
A simple recommended baseline
If you want the fastest path to better visibility:
- Install kube-prometheus-stack
- Add Grafana dashboards
- Centralize logs with Loki or your cloud log service
- Export and inspect Kubernetes events
- Add alerts for:
- Node NotReady
- Pod restarts / CrashLoopBackOff
- Deployment unavailable
- API server/etcd issues
- Disk/memory pressure
- Make sure apps have readiness/liveness/startup probes
If you want, I can also give you:
- a recommended Grafana dashboard list
- a Prometheus alert rule starter set
- or a step-by-step setup for EKS/GKE/AKS