KUBERNETES · KCNA · CHAPTER 9

Cloud Native Observability

Knowing what's happening inside a distributed system, and why, from the data it generates itself.

16 min readKCNA domain: Cloud Native Architecture (12%)Level: beginner

From point A to point B

Point A: you have applications spread across dozens of pods that scale on their own. When something is slow, where do you look? Point B: by the end of this chapter you'll know which data tells you what's happening and why, how to set reliability targets, and how to set up monitoring with Prometheus and Grafana, both on Docker and on Kubernetes.

This chapter completes the Cloud Native Architecture domain (12% of the KCNA exam). It's a long chapter because observability is the competency with the most hands-on content in the domain.

What you'll cover
  1. Logs, metrics and traces
  2. SLI, SLO, SLA and the error budget
  3. Prometheus: architecture, exporters and metrics
  4. Monitoring containers and Kubernetes
  5. Cost management in the cloud

What observability is

Observability is the ability to understand and measure a system's state from the data it generates itself. It's not just about knowing what failed, but why.

The difference from classic monitoring matters. Monitoring means watching for what you already know can fail: a full disk, a server that's down. Observability is for the unexpected: in a dynamic, distributed environment, with microservices that come and go, it lets you ask the data new questions and get answers that help you act. It also makes it easier for teams to work together, because everyone looks at the same data.

Logs, metrics and traces

Observability relies on three kinds of data, known as its three pillars:

The three pillars of observability Logs are timestamped text messages that tell what happened. Metrics are numbers measured over time, such as CPU use or requests per second. Traces follow one request hop by hop across services, with the time spent in each one. LOGS what happened timestamp + message 06:41:13 ERROR payment timeout after 3000ms Fluent Bit · Loki · Elasticsearch METRICS how much, how often numbers over time cpu 62% · 840 req/s p95 latency 180 ms Prometheus · Grafana TRACES where the time goes one request, hop by hop web 20ms → api 35ms → db 110ms OpenTelemetry · Jaeger

Each pillar answers a different question. Diagram: The House of Routing.

  • Logs: text messages with a timestamp. They tell you what happened, in detail. In Kubernetes, containers write to standard output, and an agent such as Fluent Bit or Fluentd, deployed as a DaemonSet, collects them and sends them to a central store.
  • Metrics: numeric values measured over time, such as CPU usage, memory, errors or latency. They're cheap to store and perfect for alerts and trends.
  • Traces: they follow a request hop by hop through every service it passes through, with the time spent in each one. They're the tool for finding where time is lost in a microservices architecture. Jaeger is the best-known CNCF project for storing and viewing them.
2026-10-27T06:41:12Z INFO  checkout order=8812 user=4410 total=59.90
2026-10-27T06:41:13Z ERROR payment order=8812 provider=timeout after=3000ms
One standard for all three. OpenTelemetry, a CNCF project, defines how to generate and send logs, metrics and traces with the same libraries and the same protocol. That way you instrument your code once and choose later where to store the data.

SLI, SLO and SLA

Measuring for the sake of it doesn't help. You have to decide which measurement matters to the user and which value is acceptable. That's what three concepts from SRE practice are for:

  • SLI (Service Level Indicator): a measurement of the service you provide, such as latency, availability or error rate. Not every metric works as an SLI: the best ones reflect the user's experience, which is why error rate is usually more useful than plain uptime.
  • SLO (Service Level Objective): the target value or range for an SLI. For example, "latency below 100 ms". It quantifies the reliability the product promises the customer.
  • SLA (Service Level Agreement): the contract between the provider and the customer that guarantees a level of service, with consequences, such as credits or penalties, if it isn't met.
SLI, SLO, SLA and the error budget The SLI is what you measure, for example the share of successful requests. The SLO is the target for that measure, 99.9% over 30 days, which leaves an error budget of 0.1%, about 43 minutes a month. The SLA is the contract with the customer, usually looser than the SLO, with penalties if it is missed. SLI · what you measure successful requests ÷ total requests = 99.95% this month SLO · your target 99.9% over 30 days error budget: 0.1% ≈ 43 min per month SLA · the contract 99.5% promised to the customer miss it → credits error budget left this month: 73%

The SLI measures, the SLO sets the goal and the SLA sets the consequences. Diagram: The House of Routing.

The SLO gives you the error budget: if the target is 99.9%, you can afford to fail the remaining 0.1%. While there's budget left, the team can take risks with new deployments; once it runs out, stability comes first.

SLI  share of HTTP requests answered without error in under 300 ms
SLO  99.9% over 30 days
     error budget = 0.1% → about 43 minutes of failures per month
SLA  below 99.5% in a month, the customer gets a 10% credit
A rule to memorize. The SLI is what you measure, the SLO is what you want to achieve and the SLA is what you guarantee by contract. The SLA is usually less strict than the SLO, so you have some margin before paying penalties.

Prometheus

Prometheus is an open source monitoring system, graduated in the CNCF, that collects metrics from many sources, stores them, and lets you query them, visualize them and create alerts. It's designed for one specific kind of data: numeric time series, such as CPU or memory usage, disk space, availability, latency or pending requests.

Important for the exam. Prometheus works only with metrics. It doesn't collect logs, traces or events.

Its architecture has three main parts:

  • Collection (retrieval): requests the metrics from the targets.
  • Time series database (TSDB): stores them.
  • HTTP server: answers queries in PromQL, its query language, on port 9090.
Prometheus architecture Prometheus pulls metrics over HTTP from the /metrics endpoint of its targets: exporters such as node exporter, applications instrumented with client libraries, and targets found through Kubernetes service discovery. Short jobs push to a Pushgateway, which Prometheus also scrapes. The server stores time series in its database and answers PromQL queries. Alert rules go to Alertmanager, which notifies by email or Slack, and Grafana draws the dashboards. TARGETS · /metrics node exporter :9100 app + client library kube-state-metrics short job → Pushgateway PULL (scrape) PROMETHEUS SERVER :9090 retrieval service discovery time series database HTTP server · PromQL alert rules ALERTMANAGER :9093 email · Slack · PagerDuty GRAFANA dashboards with PromQL Prometheus stores numbers over time only: no logs, no traces.

Prometheus requests metrics from its targets, stores them and notifies Alertmanager. Diagram: The House of Routing.

Prometheus follows a pull model: it visits each target at regular intervals and reads its /metrics endpoint, instead of waiting for the data to be sent to it. Each of those reads is called a scrape. That way, if a target stops responding, Prometheus notices right away. For short jobs that finish before the next scrape, there's the Pushgateway, where they leave their metrics for Prometheus to collect.

Around the server there are two more pieces: Alertmanager, which groups alerts and sends them by email, Slack or PagerDuty, and Grafana, which isn't part of Prometheus but is the usual way to build dashboards with its data.

Exporters and configuration

What if the application or system doesn't offer a /metrics endpoint? There are two solutions:

  • Exporters: programs that collect a system's metrics and expose them in Prometheus format. The best known is node exporter, which publishes a Linux machine's metrics: CPU, memory, disk and network. There are also exporters for databases, web servers and almost anything else.
  • Client libraries: for Go, Python, Java, Ruby, Rust and other languages. You use them in your own code to expose business metrics: number of errors, runs, request latency or job duration.
# download node_exporter from prometheus.io/download, then:
tar xvf node_exporter-*.linux-amd64.tar.gz
cd node_exporter-*.linux-amd64 && ./node_exporter &
curl http://localhost:9100/metrics | head        # it listens on port 9100

Installing the exporter isn't enough: Prometheus is very static, and you have to tell it where to fetch metrics from. You do that in its configuration file, prometheus.yml, with one job per group of targets. The default prometheus job makes Prometheus monitor itself.

# /etc/prometheus/prometheus.yml
global:
  scrape_interval: 15s          # how often Prometheus pulls the targets

scrape_configs:
  - job_name: prometheus        # the default job: Prometheus watches itself
    static_configs:
      - targets: ["localhost:9090"]

  - job_name: nodes
    static_configs:
      - targets: ["192.168.1.11:9100", "192.168.1.12:9100"]
promtool check config /etc/prometheus/prometheus.yml
sudo systemctl restart prometheus
# or, if started with --web.enable-lifecycle:
curl -X POST http://localhost:9090/-/reload

Prometheus metrics

Every metric has a name, some labels (key-value pairs) and a value. The HELP and TYPE lines describe the metric and say what type it is:

# HELP http_requests_total Total HTTP requests handled.
# TYPE http_requests_total counter
http_requests_total{method="GET",code="200",path="/api"} 10427
http_requests_total{method="GET",code="500",path="/api"} 13

Each combination of name and labels forms a separate time series, and each sample is stored with a Unix timestamp: the seconds elapsed since January 1, 1970, UTC. Labels let you filter and group, for example by method or by response code. But use them wisely: a label with unlimited values, such as a user ID, creates millions of series and can bring Prometheus down. Internally, even the metric name is a special label, __name__.

TypeWhat it measuresExamples
CounterHow many times something happened. It only goes up (or resets to zero on restart)Total requests, exceptions, jobs run
GaugeThe current value, which can go up and downCPU in use, free memory, concurrent requests
HistogramHow long something takes or how big it is, grouped into ranges (buckets)Response time, request size
SummarySimilar to a histogram, but calculates percentiles on the client itself95th percentile latency

With PromQL you turn those series into answers:

node_memory_MemAvailable_bytes                       # gauge: memory available now
rate(http_requests_total[5m])                        # counter → requests per second
sum by (code) (rate(http_requests_total[5m]))        # grouped by status code
histogram_quantile(0.95,
  sum by (le) (rate(http_request_duration_seconds_bucket[5m])))   # 95th percentile latency

Monitoring containers

With Docker there are two sources of metrics, and they complement each other:

  • Docker engine metrics: the state of the daemon itself. You enable them with the metrics-addr option in daemon.json.
  • cAdvisor: an agent that runs as a container and measures each container's usage, such as CPU, memory, network and disk.
# 1. Docker engine metrics: /etc/docker/daemon.json
{ "metrics-addr": "127.0.0.1:9323" }
sudo systemctl restart docker

# 2. Per-container metrics with cAdvisor
docker run -d --name cadvisor -p 8080:8080 \
  -v /:/rootfs:ro -v /var/run:/var/run:ro -v /sys:/sys:ro \
  -v /var/lib/docker/:/var/lib/docker:ro \
  gcr.io/cadvisor/cadvisor:v0.49.1

Then, in Prometheus, you add one job for each source:

scrape_configs:
  - job_name: docker
    static_configs:
      - targets: ["192.168.1.20:9323"]
  - job_name: cadvisor
    static_configs:
      - targets: ["192.168.1.20:8080"]

Monitoring Kubernetes

You can monitor a cluster from an external Prometheus, but the recommended approach is to install it inside the cluster. In Kubernetes there are three levels to monitor: the applications, the containers and the cluster itself with its components. Covering them takes several pieces:

  • node exporter as a DaemonSet: instead of installing it by hand on every node, a DaemonSet puts a pod with the exporter on each node, including nodes added later.
  • kube-state-metrics: Prometheus doesn't know the state of Kubernetes objects on its own. This component translates it into metrics: desired and available replicas, pod restarts, Deployments that aren't progressing…
  • kubelet and cAdvisor: the kubelet on each node already includes cAdvisor and exposes each container's usage.
  • Service discovery: Prometheus queries the Kubernetes API to find only the pods, Services and nodes it should monitor, with no fixed IP lists.
Monitoring Kubernetes with kube-prometheus-stack Inside the cluster, a node exporter pod runs on every node as a DaemonSet, kube-state-metrics reports the state of Kubernetes objects, and the kubelet exposes container metrics through cAdvisor. Prometheus finds all of them through the Kubernetes API, Alertmanager sends the alerts and Grafana shows the dashboards. The Helm chart kube-prometheus-stack installs everything, managed by the Prometheus Operator. CLUSTER · helm install kube-prometheus-stack NODE 1 node-exporter (DaemonSet) kubelet · cAdvisor NODE 2 node-exporter (DaemonSet) kubelet · cAdvisor KUBE-STATE-METRICS pods, deployments, replicas, restarts PROMETHEUS service discovery via the Kubernetes API ALERTMANAGER alerts → Slack, email GRAFANA ready-made dashboards

kube-prometheus-stack installs Prometheus, Alertmanager, Grafana and the exporters in the cluster. Diagram: The House of Routing.

Installing it all by hand is complex and error-prone. The recommended way is to use Helm, the Kubernetes package manager. A Helm chart is a collection of templates and YAML files that become Kubernetes manifests: each application is packaged as its own chart. The kube-prometheus-stack chart installs everything at once:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install monitoring prometheus-community/kube-prometheus-stack \
  --namespace monitoring --create-namespace
kubectl get pods -n monitoring        # prometheus, alertmanager, grafana,
                                      # kube-state-metrics, node-exporter…
kubectl port-forward -n monitoring svc/monitoring-grafana 3000:80

This chart relies on the Prometheus Operator, which adds its own resources to Kubernetes. With a ServiceMonitor you tell Prometheus which Services to monitor, in YAML and without touching prometheus.yml:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: web
  namespace: monitoring
  labels:
    release: monitoring        # so the Prometheus of the chart picks it up
spec:
  namespaceSelector:
    matchNames: ["apps"]
  selector:
    matchLabels:
      app: web                 # Services with this label…
  endpoints:
    - port: metrics            # …are scraped on their "metrics" port
      interval: 30s

Cost management

Observability also helps you control spending. Cloud cost management means linking resource usage to what it costs and keeping it under control. It's the foundation of the FinOps practice. It has three fronts:

1. Choose the right type of infrastructure:

Instance typeHow you payWhen it makes sense
On-demandPer use, with no commitmentVariable or unpredictable workloads
ReservedA one- to three-year commitment, with a large discountStable workloads that are always on
SpotSpare capacity, very cheap, that the provider can reclaim with little noticeInterruption-tolerant jobs, such as batch or CI

2. Balance performance and cost: size each resource correctly (rightsizing), set suitable upper and lower limits for autoscaling, and choose the right performance metrics to trigger it.

3. Eliminate waste: shut down non-essential environments outside business hours and on weekends, and review the infrastructure continuously to delete what's no longer used: orphaned disks, forgotten load balancers, abandoned test environments.

Connect it to chapter 8. Well-sized requests with the VPA, an HPA that reduces replicas at night and a Cluster Autoscaler that removes empty nodes are also tools for saving money.

KCNA-style challenge

Answer before you open the solution. Getting it wrong here is the cheapest way to learn.

1. Which pillar of observability follows a request across several services?

Traces. Logs record events and metrics measure values over time.

2. "Latency must be below 100 ms 99% of the time." Is this an SLI, an SLO or an SLA?

An SLO: it's a target for an SLI, latency. It would be an SLA if it were a contract with consequences for the provider.

3. How does Prometheus get metrics from its targets?

With a pull model: it visits each target's /metrics endpoint at regular intervals.

4. Which metric type would you use for a node's free memory?

A gauge, because the value goes up and down. A counter can only go up.

5. Prometheus can't see how many replicas a Deployment has available. What's missing?

kube-state-metrics, which turns the state of Kubernetes objects into metrics.

Key takeaways

  • Observability explains the why from the system's own data: logs, metrics and traces.
  • OpenTelemetry standardizes how all three are generated and sent; Jaeger stores traces and Fluent Bit collects logs.
  • The SLI is what you measure, the SLO is the goal and the SLA is the contract; the error budget is the margin the SLO leaves.
  • Prometheus stores only numeric metrics, follows a pull model over /metrics and is queried with PromQL.
  • Exporters and client libraries expose metrics; prometheus.yml says which targets to scrape.
  • Metric types: counter, gauge, histogram and summary.
  • On Kubernetes: node exporter as a DaemonSet, kube-state-metrics, and kube-prometheus-stack with Helm.
  • Cost management: on-demand, reserved and spot instances, rightsizing, and removing unused resources.

With this chapter you close the Cloud Native Architecture domain. The next one brings the last domain: application delivery, with CI/CD and GitOps.

Official resources

Source and credits. Chapter written from Jesús Espinoza's study notes on KodeKloud's KCNA course (January to April 2026). Text drafted with AI assistance; original diagrams by The House of Routing. Technical details and configuration examples were checked against the official Prometheus, Kubernetes, OpenTelemetry and CNCF documentation.

Navigate