Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Kubernetes observability: key signals and pitfalls to avoid

By updated

Improve this page

Kubernetes generates hundreds of metrics per pod, per node, per control plane component. Without a strategy, you collect everything, store everything, and understand nothing. This guide teaches you to identify the key signals that reveal real problems (OOMKilled, pending pods, excessive restarts, nodes not ready), to tell apart the 3 metrics sources (kube-state-metrics, cAdvisor, kubelet), and to avoid the pitfalls that blow up your cardinality and your costs. By the end, you will know how to set up effective Kubernetes monitoring that detects real problems without drowning your Prometheus (in French), the software that collects and stores metrics.

What you will learn

  • The 4 layers of K8s observability: application, container, node, control plane, and why you must cover each one
  • The 3 metrics sources: kube-state-metrics, cAdvisor, kubelet, their role, what they expose, how to scrape them properly
  • The 5 key signals: OOMKilled, pod restarts, pending pods, node not ready, CPU throttling, the exact metrics and the PromQL queries
  • Kubernetes logs: pod stdout/stderr, control plane logs, volume pitfalls
  • The cardinality trap: why K8s labels blow up Prometheus and how to protect yourself
  • Noisy neighbors: detecting and isolating workloads that over-consume shared resources
  • Essential alerts: 8 production-ready alerts for a minimal K8s cluster
  • Anti-patterns: the classic mistakes that make your monitoring useless or ruinous

Prerequisites

This guide assumes you can read a Kubernetes manifest (Deployment, requests and limits) and that you have followed the PromQL lesson, the query language of Prometheus: rate(), sum by and label filters are enough. The notions of cardinality and labels are recalled along the way; the metrics fundamentals (in French) detail them if they are new to you.

The 4 Kubernetes observability layers

In Kubernetes, metrics come from 4 different layers. Each layer answers distinct questions, and missing one of them creates blind spots.

LayerWhat it measuresExample questions
ApplicationThe business behaviour of your codeHow many requests? What error rate? What latency?
ContainerThe resource consumption of each containerHow much CPU/memory used? Any OOMs? Any throttling?
NodeThe health of the host machineDisk full? Network saturated? Kernel panics?
Control planeHow Kubernetes itself is runningIs the API server responding? Is the scheduler placing pods? Is etcd healthy?

Kubernetes does not know your application. The RED metrics (Request rate, Error rate, Duration) or business metrics (orders placed, connected users) must be exposed by your code: the container, node and control plane layers come from the infrastructure, but the application layer is yours to instrument.

The 3 Kubernetes metrics sources

Kubernetes exposes its metrics through 3 distinct components. Each one has a different role, and mixing them up leads to redundant or incomplete dashboards.

On the diagram, look at who is queried and by whom: Prometheus, at the bottom, fetches the metrics of each source with an HTTP request on its endpoint. kube-state-metrics reads the state of objects from the API server, while cAdvisor, built into the kubelet, measures the containers of the node. The three sources are distinct endpoints.

Prometheus queries three endpoints: kube-state-metrics, which reads the state of objects from the API server, the kubelet for node health, and cAdvisor, built into the kubelet, for container consumption.watches:8080/metrics:10250/metrics:10250/metrics/cadvisor​     Prometheus​     scrapekube-state-metricsobject statekubeletnode healthcAdvisorcontainer usageAPI serverKubernetes
Source · SVG
Esc to close, + and − to zoom, scroll to move around. 100 %

kube-state-metrics: the state of K8s objects

kube-state-metrics (KSM) listens to the Kubernetes API server and converts the state of objects (pods, deployments, nodes, etc.) into Prometheus metrics.

What it exposesWhat it does not do
Number of pending, running, failed podsCPU/memory consumption of containers
Desired vs current number of replicasHost node metrics
Reason for the last restart (OOMKilled, Error, etc.)Application metrics
State of PVCs (bound, pending)Network latency
Labels and annotations of K8s objectsLogs

Example metrics:

  • kube_pod_status_phase{phase="Pending"}, pods waiting to be scheduled
  • kube_pod_container_status_restarts_total, restart counter
  • kube_pod_container_status_last_terminated_reason{reason="OOMKilled"}, OOM
  • kube_deployment_status_replicas_unavailable, missing replicas

Installation: deploy kube-state-metrics in the kube-system namespace (official Helm chart) and configure Prometheus to scrape the service; the guide Prometheus on Kubernetes (in French) details the deployment with kube-prometheus-stack.

cAdvisor: container resource consumption

cAdvisor (Container Advisor) is built into the kubelet. It measures the real consumption of each container: CPU, memory, network, disk I/O.

What it exposesWhat it does not do
CPU used per container (container_cpu_usage_seconds_total)State of K8s objects (replicas, pending)
Memory used (container_memory_usage_bytes)Reason for restarts
Disk I/O (container_fs_reads_bytes_total)Control plane metrics
Network per pod (container_network_receive_bytes_total)Application metrics

Example metrics:

  • container_cpu_usage_seconds_total, CPU used (cumulative)
  • container_memory_working_set_bytes, memory usage minus inactive cache (inactive_file)
  • container_cpu_cfs_throttled_periods_total and container_cpu_cfs_periods_total, the periods in which the CPU limit throttled the container, and the total periods (signal no. 5 explains them)

Prefer container_memory_working_set_bytes over container_memory_usage_bytes to size your requests and limits: the latter includes the file cache and inflates the values, whereas working_set removes the inactive cache (inactive_file) and stays more representative of the memory actually used. An OOMKilled happens when the container exceeds its memory limit (cgroup): working_set lets you anticipate this threshold without being the value the kernel compares.

Kubelet metrics: node health

The kubelet exposes its own metrics about how the node works: pod lifecycle operations, storage, runtime.

What it exposesWhat it does not do
Latency of pod operations (start, stop, sync)Application consumption
Runtime (CRI) errorsState of K8s objects
Disk space available for podsControl plane metrics
Number of pods per nodeApplication logs

Example metrics:

  • kubelet_pod_start_duration_seconds, pod start time
  • kubelet_volume_stats_available_bytes, available space per PVC
  • kubelet_running_pods, active pods on the node

Scraping in production: auth, TLS and ServiceMonitors

The kubelet endpoints (/metrics, /metrics/cadvisor) run on port 10250, which is secured (TLS + authentication). In production, avoid "raw scraping" of node IPs without hardening.

Comparison table of the 3 sources

The column to remember is Deployed by: only kube-state-metrics is a component you install yourself, the other two are already there as soon as a node joins the cluster. A classic oversight is therefore to monitor container consumption, available without installing anything, while staying blind to Pending pods and OOMKilled, which require deploying KSM.

SourceDeployed byTypical endpointMain use case
kube-state-metricsYou (Helm/manifest)kube-state-metrics:8080/metricsK8s states: pending, OOMKilled, replicas
cAdvisorBuilt into the kubelet<node>:10250/metrics/cadvisorResource usage: CPU, memory, I/O
kubeletKubernetes<node>:10250/metricsNode health: pod lifecycle, volumes

The 5 key signals to watch

These 5 signals are the starting point for monitoring a Kubernetes cluster. Each one has a precise metric, a PromQL query and a recommended alert.

1. OOMKilled, the container runs out of memory

Symptom: the pod restarts with no obvious explanation, the application loses its sessions or its in-flight transactions.

Metric: kube_pod_container_status_last_terminated_reason{reason="OOMKilled"}

PromQL query (recently OOMKilled pods, correlated with restarts):

increase(kube_pod_container_status_restarts_total[15m]) > 0
and on (namespace, pod, container)
kube_pod_container_status_last_terminated_reason{reason="OOMKilled"} == 1

The correlation with restarts is necessary: last_terminated_reason gives the reason for the last stop, so a container OOMKilled 3 days ago that has been running since keeps the value 1 with no recent event. With increase(restarts), the alert only covers recent OOMs.

Alert:

- alert: ContainerOOMKilled
expr: |
increase(kube_pod_container_status_restarts_total[15m]) > 0
and on (namespace, pod, container)
kube_pod_container_status_last_terminated_reason{reason="OOMKilled"} == 1
for: 0m
labels:
severity: warning
annotations:
summary: "Container {{ $labels.container }} in pod {{ $labels.pod }} was OOMKilled (recent)"

Actions:

  1. Check the current memory requests/limits against real consumption
  2. Investigate memory leaks (profiling, heap dumps)
  3. Check the GC configuration (Java, Go, Node.js)
  4. Raise the limits only if the consumption is legitimate: on a memory leak, raising the limit only delays the problem

2. Pod restarts, the crash-restart loop

Symptom: a pod restarts in a loop (CrashLoopBackOff), the application is unstable.

Metric: kube_pod_container_status_restarts_total

PromQL query (pods with > 0 restarts over 15 min):

rate(kube_pod_container_status_restarts_total[15m]) > 0

Alert:

- alert: PodCrashLooping
expr: rate(kube_pod_container_status_restarts_total[15m]) > 0
for: 5m
labels:
severity: warning
annotations:
summary: "Pod {{ $labels.pod }} is crash looping"

Actions: examine the logs (kubectl logs --previous), check the probes (misconfigured liveness/readiness), examine the exit codes.

3. Pending pods, the scheduler cannot place

Symptom: pods stay Pending, deployments do not progress, the autoscaler does not scale.

Metric: kube_pod_status_phase{phase="Pending"}

PromQL query (pods pending for > 5 min):

sum by (namespace, pod) (kube_pod_status_phase{phase="Pending"}) > 0

A Pending pod is sometimes normal during a rollout (image pulls, init containers, volume mounts): the alert below carries for: 5m to rule out these short waits. To tell the real causes apart, examine the pod's Events:

  • FailedScheduling, insufficient resources, constraints (affinity, taints) or unbound PVC (message "pod has unbound immediate PersistentVolumeClaims");
  • FailedMount, failure to mount or attach a volume on the kubelet side;
  • Failed then BackOff, image pull failure (image not found or authentication refused); the container then shows the ImagePullBackOff state, which is a waiting state and not an Event.
Terminal window
kubectl describe pod <pod-name> -n <namespace> | grep -A10 Events

Alert:

- alert: PodPendingTooLong
expr: sum by (namespace, pod) (kube_pod_status_phase{phase="Pending"}) > 0
for: 5m
labels:
severity: warning
annotations:
summary: "Pod {{ $labels.pod }} is pending for more than 5 minutes"
runbook_url: "https://example.com/runbooks/pod-pending"

Actions: examine the events (kubectl describe pod), check the available resources (cluster CPU/memory), the constraints (nodeSelector, affinity, taints/tolerations), the PVCs (pending storage).

4. Node not ready, the node is failing

Symptom: the pods on this node are evicted, they move to other nodes, the cluster capacity decreases.

Metric: kube_node_status_condition{condition="Ready",status="true"}

PromQL query (nodes not ready, with aggregation by node):

sum by (node) (kube_node_status_condition{condition="Ready",status="true"}) == 0

Alert:

- alert: NodeNotReady
expr: sum by (node) (kube_node_status_condition{condition="Ready",status="true"}) == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Node {{ $labels.node }} is not ready"

Actions: check the node's network connectivity, the state of the kubelet (systemctl status kubelet), system resources (disk, memory), the kubelet logs (journalctl -u kubelet -f).

5. CPU throttling, the container is capped

Symptom: the application is slow, p99 latency rises, but CPU usage looks "normal".

Metrics: container_cpu_cfs_throttled_periods_total and container_cpu_cfs_periods_total

PromQL query (share of CFS periods throttled, per container):

rate(container_cpu_cfs_throttled_periods_total{container!=""}[5m])
/ rate(container_cpu_cfs_periods_total{container!=""}[5m]) > 0.2

The kernel enforces the CPU limit in periods of 100 ms by default (this is the CFS quota, CFS being its scheduler). If the container reaches its limit before the end of a period, the kernel suspends its processes until the next one: that period then counts as throttled. The ratio gives the share of throttled periods: 0.43 means that 43% of the periods reached the limit.

These counters only exist for a container that has a CPU limit. The container!="" filter discards the series aggregated at the Pod level, whose container label is empty. An idle container has no periods: the ratio is NaN and the alert does not fire.

Alert:

- alert: ContainerCPUThrottling
expr: |
rate(container_cpu_cfs_throttled_periods_total{container!=""}[5m])
/ rate(container_cpu_cfs_periods_total{container!=""}[5m]) > 0.2
for: 5m
labels:
severity: warning
annotations:
summary: "Container {{ $labels.container }} is being CPU throttled"

Actions:

  1. Check the current CPU limits against real consumption
  2. Raise the CPU limits if the throttling is constant
  3. For latency-sensitive workloads: consider "requests only"

Kubernetes logs

Metrics tell you that a pod restarts or runs out of memory, logs tell you why. This section covers the two sources to collect: pod logs (container stdout and stderr, with their volume pitfalls) then the logs of the control plane components.

Pod logs: stdout/stderr

In Kubernetes, application logs are the stdout and stderr streams of the containers. The kubelet captures them and stores them on the node.

Collection (the guide Loki with Alloy (in French) details the full chain): deploy a DaemonSet of collectors (Grafana Alloy, Fluent Bit, Vector) that reads the /var/log/pods/ files on each node and sends them to Loki, Elasticsearch, or your logs backend.

Common pitfalls:

PitfallConsequenceSolution
Logs too voluminousStorage explodes, high costsFilter at the source, sample, set short retentions
Unstructured logsSearch impossible, fragile parsingLog in JSON, define a standard schema
No K8s labelsImpossible to correlate with metrics/tracesEnrich with pod, namespace, container at collection time

Control plane logs

The control plane components (API server, scheduler, controller manager, etcd) write their logs to stdout, visible through kubectl logs in the kube-system namespace or through journald on the control plane nodes.

ComponentUseful logsUse case
kube-apiserverSlow requests, authentication errors, rate limitingRBAC debugging, audit, API performance
kube-schedulerPlacement failures, reasons for pendingUnderstand why a pod is not scheduled
kube-controller-managerReconciliation errorsDebug deployments, replicasets, jobs
etcdLatencies, compactions, leader electionsDiagnose an unstable cluster

On managed clusters (EKS, GKE, AKS), you often have no access to the control plane logs, or only through an export to your observability stack (Cloud Logging, CloudWatch). On self-hosted clusters, configure the collection explicitly.

The cardinality trap

Kubernetes generates dynamic labels: pod, container, uid, revision, node. These labels change with every recreated Pod (rollout, eviction, scaling). The result: your cardinality explodes.

The problem

Prometheus stores each unique combination of metric + labels as a time series (the governance (in French) guide details the costs of cardinality and retention). The number of series is the product of the number of values of each label.

Catastrophic example:

container_cpu_usage_seconds_total{
namespace="production",
pod="payment-api-abc123",
container="payment",
node="node-1"
}

With 50 pods × 20 containers × 10 nodes, a single metric already has thousands of combinations. cAdvisor exposes dozens of metrics per container, and every rolling update creates new pod values: you quickly reach millions of series, and Prometheus collapses.

Dangerous labels

The classification criterion is not the number of values at a given moment, but the speed at which new values appear. A node label stays stable for months; a pod label changes with every recreated Pod (rollout, eviction, scaling), and every vanished value leaves behind an inactive series that Prometheus keeps until the retention expires. This phenomenon, called churn, is what drives memory consumption up long before the number of live pods looks worrying.

LabelTypical cardinalityRisk
podUnlimited (changes with every recreated Pod)Very high
uidUnlimited (unique per object)Very high
container_idUnlimitedVery high
idUnlimited (cgroup id)Very high
namePotentially unlimitedVery high
imageHigh (changes with every tag)Medium-high
revisionPotentially highMedium
nodeNumber of nodes (often < 100)Low
namespaceNumber of namespaces (often < 50)Low

How to protect yourself

Principle: first remove the series that make no sense (system cgroups, with no pod label), then the very high cardinality labels. Only drop an entire metric if you know you do not use it (after auditing dashboards, alerts, recording rules).

1. Filter the explosive labels at scrape time (metric_relabel_configs):

scrape_configs:
- job_name: 'cadvisor'
metric_relabel_configs:
# First: discard the series with no container or pod (system
# cgroups), which labeldrop would make identical
- source_labels: [container, pod]
regex: ';'
action: drop
# Then: remove the labels with unlimited cardinality
- action: labeldrop
regex: 'id|name|image|container_id|uid'

The drop comes before the labeldrop for a precise reason. On cAdvisor, the id label (cgroup path) is the only difference between many series with no pod label, such as the system cgroups / or /system.slice. Once id is removed, these series become identical. The first rule therefore discards the series where container and pod are both empty: the ; regex matches the two empty values joined by ;. Testing pod as well avoids losing the per-pod network metrics, whose container label can be empty or absent.

This drop targets precise series, never entire metrics. Avoid dropping a complete metric before auditing its usage: an action: drop on container_cpu.* would make you lose exactly the metrics that the alerts of this page need.

2. Use bounded labels:

  • deployment, statefulset instead of pod
  • namespace, service instead of container_id
  • Normalise paths: /users/12345 → /users/:id

3. Monitor your cardinality:

# Top 10 metrics by number of series
topk(10, count by (__name__) ({__name__!=""}))
# Series per label for a metric
count by (pod) (container_cpu_usage_seconds_total)

4. Alert on growth:

- alert: HighCardinalityMetric
expr: count by (__name__) ({__name__=~"container_.*"}) > 100000
for: 5m
labels:
severity: warning
annotations:
summary: "Metric {{ $labels.__name__ }} has very high cardinality"

Noisy neighbors: detecting workloads that over-consume

In a multi-tenant cluster, a workload can consume all the resources of a node and degrade the performance of the other pods, this is the "noisy neighbor problem".

Symptoms

What characterises a noisy neighbor is that the symptoms appear on workloads that changed nothing. A deployment whose latency degrades with no new release or traffic increase should make you look at its neighbours on the node, not at its own code. The cross-check is done with the node label: list the other pods of the same node over the incident window.

  • p99 latency rising on "innocent" pods
  • CPU throttling on pods that should not have any
  • Pod evictions for memory pressure
  • Pods that can no longer be scheduled (resources exhausted)

Detection metrics

The three queries below answer three distinct questions: who consumes, how much, and who is not bounded. Note the container!="" filter: cAdvisor metrics include an aggregated series for the pod sandbox, whose container label is empty. Without this filter, you count the consumption twice.

CPU per namespace (share of the total cluster consumption):

sum by (namespace) (
rate(container_cpu_usage_seconds_total{container!=""}[5m])
)
/ ignoring(namespace) group_left
sum(rate(container_cpu_usage_seconds_total{container!=""}[5m]))

Memory per namespace:

sum by (namespace) (container_memory_working_set_bytes{container!=""})

Containers without a CPU limit (noisy neighbor candidates):

count by (namespace, pod, container) (kube_pod_container_info)
unless on (namespace, pod, container)
kube_pod_container_resource_limits{resource="cpu"}

Protection

These four mechanisms act at different moments of a pod's life, and they combine. Limit Ranges step in at admission by injecting default values, which addresses the root of the problem: a container without a limit. Resource Quotas cap the cumulative consumption of a namespace. Priority Classes only come into play under pressure, to decide who is evicted first. Start with Limit Ranges, it is the only one that prevents the problem from appearing. Pod Disruption Budgets complete the picture without dealing with the noisy neighbor: they guarantee a minimum of replicas during voluntary evictions (draining a node), but not during an eviction triggered by resource pressure on the node.

MethodDescriptionWhen to use it
Resource QuotasPer-namespace limits (total CPU/memory)Multi-tenant
Limit RangesDefaults and limits per pod/containerPrevent pods without limits
Priority ClassesOrdered eviction under pressureProtect critical workloads
Pod Disruption BudgetsGuarantee a minimum of replicasHigh availability

8 essential alerts for a K8s cluster

Here is a minimal set of alerts ready for production, which covers the critical signals without excessive noise. Their writing follows the principles of Effective alerting (in French), and they reuse the five signals above plus three capacity alerts (memory close to the limit, missing replicas, pending PVC).

Two conventions structure the block and are worth keeping as they are. First the severity: only NodeNotReady is critical, because it is the only event that reduces cluster capacity with no possible action from the application. Then the runbook_url annotation, present on every rule: an alert without an associated procedure ends up ignored, and it is the runbook that turns a notification into an action. Replace the example.com domain with that of your own knowledge base.

groups:
- name: kubernetes-essential
rules:
# 1. Pod OOMKilled (recent event)
- alert: ContainerOOMKilled
expr: |
increase(kube_pod_container_status_restarts_total[15m]) > 0
and on (namespace, pod, container)
kube_pod_container_status_last_terminated_reason{reason="OOMKilled"} == 1
for: 0m
labels:
severity: warning
annotations:
summary: "Container {{ $labels.container }} was OOMKilled (recent)"
runbook_url: "https://example.com/runbooks/oomkilled"
# 2. Pod crash looping
- alert: PodCrashLooping
expr: rate(kube_pod_container_status_restarts_total[15m]) > 0
for: 5m
labels:
severity: warning
annotations:
summary: "Pod {{ $labels.pod }} is crash looping"
runbook_url: "https://example.com/runbooks/crashloop"
# 3. Pod pending
- alert: PodPendingTooLong
expr: sum by (namespace, pod) (kube_pod_status_phase{phase="Pending"}) > 0
for: 5m
labels:
severity: warning
annotations:
summary: "Pod {{ $labels.pod }} is pending"
runbook_url: "https://example.com/runbooks/pod-pending"
# 4. Node not ready
- alert: NodeNotReady
expr: sum by (node) (kube_node_status_condition{condition="Ready",status="true"}) == 0
for: 2m
labels:
severity: critical
annotations:
summary: "Node {{ $labels.node }} is not ready"
runbook_url: "https://example.com/runbooks/node-not-ready"
# 5. CPU throttling
- alert: ContainerCPUThrottling
expr: |
rate(container_cpu_cfs_throttled_periods_total{container!=""}[5m])
/ rate(container_cpu_cfs_periods_total{container!=""}[5m]) > 0.2
for: 5m
labels:
severity: warning
annotations:
summary: "Container {{ $labels.container }} is CPU throttled"
runbook_url: "https://example.com/runbooks/cpu-throttling"
# 6. Memory close to the limit
# The "> 0" filter discards containers without a limit, whose
# container_spec_memory_limit_bytes is 0 (division by zero).
- alert: ContainerMemoryNearLimit
expr: |
container_memory_working_set_bytes{container!=""}
/ (container_spec_memory_limit_bytes{container!=""} > 0) > 0.9
for: 5m
labels:
severity: warning
annotations:
summary: "Container {{ $labels.container }} memory at 90%+ of limit"
runbook_url: "https://example.com/runbooks/memory-near-limit"
# 7. Deployment replicas mismatch
- alert: DeploymentReplicasMismatch
expr: |
kube_deployment_spec_replicas
!= kube_deployment_status_replicas_available
for: 5m
labels:
severity: warning
annotations:
summary: "Deployment {{ $labels.deployment }} replicas mismatch"
runbook_url: "https://example.com/runbooks/replicas-mismatch"
# 8. PVC pending
- alert: PersistentVolumeClaimPending
expr: kube_persistentvolumeclaim_status_phase{phase="Pending"} == 1
for: 5m
labels:
severity: warning
annotations:
summary: "PVC {{ $labels.persistentvolumeclaim }} is pending"
runbook_url: "https://example.com/runbooks/pvc-pending"

Anti-patterns: what not to do

Two families emerge from the table below. The collection and storage anti-patterns (pod label, whole cAdvisor metrics, per-pod dashboards, logs at debug level or with no retention limit) cost money and stability: a saturated Prometheus, a growing bill, and nobody to say which series are really used. The coverage anti-patterns (no kube-state-metrics, alerts on containers only, logs without labels, control plane ignored) cost incident time: the monitoring runs, but it does not answer the questions you ask at three in the morning. These defects are not visible at creation: an overly broad scrape does not bother a cluster of ten pods, it brings Prometheus down when it has three hundred. So watch the trend (active series, daily log volume) rather than today's value.

If you only fix one point, pick "No kube-state-metrics": without it, four of the five key signals are no longer observable (only CPU throttling comes from cAdvisor).

Anti-patternWhy it is a problemSolution
Scraping pod as a labelCardinality explodes with every deployAggregate by deployment, service
Collecting all cAdvisor metricsHundreds of series per containerFilter at scrape time (labeldrop on explosive labels)
No kube-state-metricsImpossible to see pending, OOMKilled, replicasDeploy KSM from day one
Alerts on container metrics onlyMisses the K8s context (rollout, scaling)Combine with kube-state-metrics
Logs without K8s labelsImpossible to correlate with metrics/tracesEnrich with namespace, pod, container
Ignoring the control planeAPI server, scheduler problems invisibleCollect the control plane metrics
No resource quotasOne namespace can kill the clusterResource quotas in multi-tenant
CPU limits too lowArtificial throttling, degraded latencyConsider requests-only for sensitive workloads
Per-pod dashboards200 pods = unreadable dashboardAggregate by deployment, namespace, service
Unlimited log retentionCosts explodeShort retention (7-30 days), cold tier
Debug-level logs in productionVolume and costs multipliedInfo or warn level in production

Workflow: deploy observability on a K8s cluster

The order of these eight steps is not arbitrary. Cardinality filtering comes as early as step 2, before the dashboards and alerts, because high-cardinality series ingested before the filtering stay in memory and on disk until the retention expires: the filter erases nothing, it only stops ingesting. Conversely, resource quotas come late: they assume you know the real consumption of each namespace, information that only the previous steps give you. Treat steps 7 and 8 as recurring work, not as a one-off setup.

  1. Deploy kube-state-metrics

    Official Helm chart or manifest. Check that the service is scraped by Prometheus. You should see the kube_* metrics.

  2. Configure cAdvisor / kubelet scraping with ServiceMonitors

    Use the ServiceMonitors/PodMonitors of your stack (kube-prometheus-stack). Configure RBAC and TLS certificates. Add metric_relabel_configs to filter the dangerous labels (id, name, image, container_id, uid), watching out for the collisions described above.

  3. Deploy a log collector

    Grafana Alloy, Fluent Bit or Vector as a DaemonSet; Promtail has been end-of-life since March 2026 and must no longer be chosen for a new deployment. Configure the enrichment with the K8s labels (namespace, pod, container) and the shipping to Loki or your backend.

  4. Create the base dashboards

    A Cluster overview dashboard (nodes, pending pods, restarts), built with the method of useful dashboards (in French). A Namespace dashboard (CPU/memory per deployment, top consumers). A Pod debugging dashboard (logs + metrics for investigation).

  5. Deploy the 8 essential alerts

    PrometheusRule with the OOMKilled, crash loop, pending, node not ready, throttling, memory near limit, replicas mismatch, PVC pending alerts. Add the runbook_url annotations pointing to your runbooks.

  6. Configure resource quotas (multi-tenant clusters)

    Per-namespace limits for CPU and memory. Limit ranges for the pod defaults.

  7. Monitor your cardinality

    Dedicated dashboard: top metrics by series, growth over time. Alert if a metric exceeds a threshold.

  8. Iterate on the filters and aggregations

    Every week, identify unused metrics and redundant labels. Refine your recording rules to pre-aggregate.

Sources

Official references on the metrics and endpoints described above.

Put it into practice

In the lab, Prometheus already collects the cluster's three metric sources: kube-state-metrics, the kubelet and cAdvisor. It has no alert rule yet. In the signaux namespace, the memoire-courte Pod is killed regularly because it exceeds its memory limit, and calcul-serre is throttled all the time by its CPU limit. A third Pod, temoin-calme, also has limits but never reaches them.

You write two alerts, SignauxOOMKilled and SignauxThrottling, from the queries of signals 1 and 5 on this page. Prometheus reads its rules from the prometheus-regles ConfigMap in the supervision namespace, in the groups format shown in the section on the 8 alerts. It only picks them up after a reload, and an alert stays pending for the duration of its for: before moving to firing.

Validation queries the Prometheus API: it reads the firing alerts and checks that SignauxOOMKilled targets memoire-courte, that SignauxThrottling targets calcul-serre, and that neither targets temoin-calme. Wait until both of your alerts are firing before running the check.

Key points

  1. Kubernetes exposes metrics at 4 layers: application (you instrument it), container (cAdvisor), node (kubelet), control plane (API server, scheduler, etcd)

  2. The 3 main sources: kube-state-metrics for the K8s state (pending, OOMKilled, replicas), cAdvisor for resource consumption (CPU, memory, I/O), kubelet for node health

  3. The 5 key signals: OOMKilled (memory exceeded), pod restarts (crash loop), lasting Pending pods (scheduler blocked, volume or image), node not ready (failing node), CPU throttling (share of the CFS periods in which the CPU limit throttled the container)

  4. Cardinality explodes with dynamic labels (pod, uid, container_id). Filter at scrape time with labeldrop, aggregate by deployment or service, monitor with dedicated PromQL queries

  5. Noisy neighbors are detected by comparing consumption per namespace/deployment. Protect yourself with resource quotas and limit ranges

  6. K8s logs are the stdout/stderr of the pods. Enrich them with the K8s labels at collection time, limit the volume with short retentions

  7. For the control plane (self-hosted clusters), collect the metrics of the API server, scheduler, controller manager, etcd. On managed clusters, use the provider's integration

  8. Start with 8 essential alerts: OOMKilled (event-based), crash loop, pending, node not ready, throttling, memory near limit, replicas mismatch, PVC pending

Knowledge check

Check that you have the essentials of this guide. The questions only cover what has just been explained here.

Knowledge check

Check what you have learned with this interactive quiz

6 questions
6 min
70% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer