Sign in Start free

EngineeringFree course

Container and Kubernetes Monitoring in Practice

Build observability for the Rimal tracker on Kubernetes: telemetry layers, Prometheus metrics, rates and percentiles, cardinality, cgroup CPU throttling and memory, pod health and right-sizing, alerts with Alertmanager, CRI logs to Loki, OpenTelemetry traces with tail sampling, SLOs with burn-rate alerts, audit-log and Falco security detections, and observability at enterprise scale.

  • Level Junior → Expert
  • Time 240 min
  • Modules 10
  • Exercises 27 with worked solutions
  • Includes Lab, 5-question quiz, references

What you'll learn

  • Name the telemetry layers and signals of a container platform
  • Collect and query Prometheus metrics, including container throttling and memory
  • Diagnose pod failures and right-size requests from data
  • Build log and trace pipelines and alert on SLO burn rates
  • Detect attacks from audit logs and runtime events and respond without losing evidence

Each lesson is tagged Junior, Mid or Expert, so you can start where you are. Finish with the lab and the quiz; a score of 4 out of 5 marks the course complete in this browser.

The lessons below are in English for now, because they quote technical names, commands and log fields. An Arabic version is planned.

Course map

Each module moves from fundamentals to applied work to an expert challenge. Exercises have worked solutions: try first, then open the solution. 10 modules · 27 exercises · ~4 hours

  1. 0Start here: what to monitor in a container platformJuniorMidExpert20 min · 2 exercises
  2. 1Metrics: the Prometheus modelJuniorMidExpert25 min · 3 exercises
  3. 2Containers and nodes: cgroups, throttling and memoryJuniorMidExpert20 min · 3 exercises
  4. 3Kubernetes state: pods, restarts and right-sizingJuniorMidExpert25 min · 3 exercises
  5. 4Queries and alerts that people trustJuniorMidExpert25 min · 3 exercises
  6. 5Logs: from container stdout to searchable eventsJuniorMidExpert25 min · 3 exercises
  7. 6Traces with OpenTelemetryJuniorMidExpert25 min · 3 exercises
  8. 7SLOs, error budgets and burn-rate alertsJuniorMidExpert25 min · 3 exercises
  9. 8Security monitoring: audit logs and runtimeJuniorMidExpert25 min · 3 exercises
  10. 9Enterprise observability; cheat sheet and assessmentJuniorMidExpert25 min · 1 exercises

No prior experience is needed. Module 0 covers the architecture, installation and configuration, and sets up the project you extend in every module. Each command is labelled with its impact (read-only, changes files, changes the system, uses the network). Work on a computer or virtual machine you control.

0

Start here: what to monitor in a container platform

Goal: Understand why containers change monitoring, the telemetry layers and signals, the RED and USE methods, and the course project.

20 min

Many layers, short lives

Monitoring tells you that something is wrong; observability lets you find out why, from the telemetry the system emits. Containers make both harder: pods live for minutes, move between nodes and are identified by labels rather than host names, and one user request crosses many services. You therefore collect from six layers, label everything with Kubernetes metadata, and correlate.

Without this, the first sign of trouble is a customer complaint, and investigations stall because the failing pod has already been replaced. Security teams need the same telemetry: the API audit log and runtime events are how an attack on a cluster becomes visible.

Applicationrequests, errors, latency, business eventsRED · traces · structured logsKubernetes objectsdeployments, pods, restarts, schedulingkube-state-metrics · eventsControl planeAPI server, scheduler, etcd, audit logapiserver metrics · auditContainer runtimecgroups: CPU, throttling, memory, OOMcAdvisor via kubeletNodeCPU, memory, disk, network of the hostnode_exporter (USE)Security runtimesyscalls, files, network flowsFalco · Tetragon · Hubble
Metricsnumbers over timecheap, aggregate, alertPrometheusLogsevents with detaildebug, audit, securityLoki, ElasticsearchTracesone request across serviceswhere time goesOpenTelemetry, TempoEvents + profilesKubernetes eventsCPU and memory profileskubectl, Pyroscope
MethodForSignals
REDservices (the tracker API)Rate, Errors, Duration
USEresources (nodes, CPU, memory, disks)Utilisation, Saturation, Errors
Four golden signalsuser-facing systemslatency, traffic, errors, saturation
SLOsdeciding when to actSLI vs target, error budget, burn rate
CollectPrometheusPrometheusFluent BitFluent BitOpenTelemetryOpenTelemetryKubernetesKubernetesKubernetesHelmHelmMetricsPrometheusPrometheusThanosThanosVictoriaMetricsVictoriaMetricsLogsLokiLokiElasticsearchElasticsearchOpenSearchOpenSearchTracesOpenTelemetryOpenTelemetryJaegerJaegerVisualiseGrafanaGrafanaKibanaKibanaAlertPagerDutyPagerDutySlackSlackSecureFalcoFalcoSplunkSplunkWazuhWazuhThe observability toolchain: collection, Kubernetes, metrics, logs, traces, visualisation, alerting and security monitoring.

The project and the lab

You will build observability for the Rimal tracker running on Kubernetes (from the Kubernetes course): metrics, container and cluster health, alerts, logs, traces, SLOs and security detections. Clusters are not needed for the lab: a real tracker process exposes real Prometheus metrics, and the other exercises use real-shaped data (cgroup files, pod JSON, CRI logs, spans, audit events) so every result is reproducible.

Customerstrack shipmentsNEWTracker on Kubernetes3 replicasKubernetesPythonNEWDependenciesPostgres · Redis · carrierPostgreSQLRedisNEWPrometheusGrafanaContainer + nodekube-state-metricsAlertmanagerFluent Bit → LokiOTel Collector → TempoSLOs + burn rateAudit logFalcoSIEMLong-term storageStage 0: the tracker runs on Kubernetes; nobody can see inside it.
shell
k8smon/
├── tracker_app.py, scrape.py, cardinality.py   # modules 1
├── cgroup/…, cgroup.py                       # module 2
├── pods.json, usage.json, podhealth.py       # module 3
├── alerteval.py                              # module 4
├── logs/…, logpipe.py                        # module 5
├── spans.json, traces.py                     # module 6
├── slo.py                                    # module 7
└── audit.jsonl, audit_detect.py              # module 8

Quick check: A pod restarted at 03:10 and was replaced. Which telemetry still tells you why?

Exercise 1Junior

Which method (RED or USE) fits each: (a) the tracker API, (b) a node's disk, (c) Postgres connections?

Worked solution

(a) RED: request rate, errors, duration per route. (b) USE: utilisation, saturation (queue length, I/O wait) and errors of the disk. (c) Both: USE for the connection pool (in use, waiting, errors), RED for the queries it serves.

Exercise 2Mid

Why is labelling every signal with pod, namespace and app essential in Kubernetes?

Worked solution

Pod names and IPs change on every restart and reschedule, so the stable identity is the set of labels (app, namespace, version). Labels let you aggregate across replicas, compare versions during a rollout and join metrics, logs and traces about the same workload.

Tools in this course

PrometheusMonitor

Pull-based metrics, PromQL, alert rules.

Use it for: metrics for everything in the cluster

Integrates with: kube-prometheus-stack, Grafana

GrafanaMonitor

Dashboards across metrics, logs and traces.

Use it for: one place to look

Integrates with: Prometheus, Loki, Tempo

OpenTelemetryMonitor

Vendor-neutral SDKs and Collector for traces, metrics, logs.

Use it for: instrumenting services

Integrates with: Tempo, Jaeger, any backend

FalcoRuntime

Runtime security from kernel events.

Use it for: detecting attacks inside containers

Integrates with: Kubernetes, SIEM

Project step 0

Set up the lab

Goal: ~/k8smon holds the tracker with a /metrics endpoint and the data sets used in every module.

1

Metrics: the Prometheus model

Goal: Expose metrics, scrape them, compute rates and latency percentiles from counters and histograms, and keep cardinality under control.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

2

Containers and nodes: cgroups, throttling and memory

Goal: Read cgroup v2 CPU and memory statistics, detect CPU throttling and memory pressure, and connect them to Kubernetes requests and limits.

20 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

3

Kubernetes state: pods, restarts and right-sizing

Goal: Find unhealthy pods from Kubernetes state, explain the common failure states, and right-size requests from real usage.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

4

Queries and alerts that people trust

Goal: Write PromQL for services and containers, alert on symptoms with 'for' durations and runbooks, and route alerts with Alertmanager.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

5

Logs: from container stdout to searchable events

Goal: Collect container logs in the CRI format, join multi-line messages, add Kubernetes metadata, redact secrets, and query with LogQL.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

6

Traces with OpenTelemetry

Goal: Follow one request across services, find where time goes and where errors start, sample traces sensibly, and link traces with logs.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

7

SLOs, error budgets and burn-rate alerts

Goal: Define SLIs and SLOs for the tracker, compute the error budget, and alert on how fast it is burning with multiple windows.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

8

Security monitoring: audit logs and runtime

Goal: Configure the Kubernetes audit policy, detect exec, secret access, privileged pods and RBAC abuse, add runtime rules, and respond without destroying evidence.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

9

Enterprise observability; cheat sheet and assessment

Goal: Scale to many clusters with long-term storage, control cost and cardinality, run on-call well, and design observability for a new platform.

25 min

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

Quick reference (the cheat-sheet lessons and the PDF content)
1

Where container telemetry comes from

JuniorMid

Kubernetes audit logging is off by default on self-managed clusters and often partial on managed ones. Turn it on first.

Cloud control planeEKS / AKS / GKE API calls, IAM changes, node pool and cluster settingsCloudTrail · Activity LogKubernetes audit logEvery API request: who did what to which pod, secret or rolemost importantRuntime (eBPF)Processes, files and network inside containers: Falco, Tetragon, EDRreal-timeContainer logsApplication stdout / stderr collected by Fluent Bit or the cloud agentapp layerNode OSauditd, kubelet and containerd logs on each worker nodehostSupply chainRegistry pulls, image scan results, CI/CD pipeline and signing eventsbuild time
2

Container attack chain

JuniorMid
1Initial accessexposed dashboard,vulnerable app2Executionkubectl exec,new pod3PersistenceCronJob, DaemonSet,backdoor image4Priv. escalationprivileged pod,hostPath mount5Credential accessservice accounttokens, secrets6Impactcrypto-mining,node escape

Docker host red flags

  • Docker API on TCP 2375 with no TLS
  • /var/run/docker.sock mounted into a container
  • Containers run with --privileged or --pid=host
  • Images pulled from unknown registries

Kubernetes red flags

  • system:anonymous or system:unauthenticated allowed
  • Kubelet port 10250 reachable without auth
  • Default service account bound to cluster-admin
  • No NetworkPolicies: every pod can reach every pod
3

Kubernetes audit log detections

MidExpert
Use caseAudit log signalATT&CK
Shell into a podverb=create on pods/exec or pods/attach in production namespacesT1609
Privileged pod createdPod spec with privileged: true, hostPID, hostNetwork or a hostPath of /T1611
Cluster-admin grantedcreate ClusterRoleBinding to cluster-adminT1098
Secrets harvestedlist or get on secrets across namespaces by a service accountT1552.007
Anonymous accessAny request with user.username=system:anonymous that succeedsT1078
Persistence workloadNew DaemonSet or CronJob, especially in kube-systemT1053.007
Port-forward / proxypods/portforward or services/proxy from an unusual userT1090
Token mintingcreate on serviceaccounts/token outside CIT1528
Admission control removeddelete on ValidatingWebhookConfiguration or policy objectsT1562
Mass failed requestsMany 403 responses from one identity (RBAC probing)T1613
4

Queries

MidExpert

Table and field names differ by platform and log pipeline. Check yours first.

jq · exec into pods from a raw audit.log
jq -c 'select(.objectRef.subresource=="exec")
  | {t:.requestReceivedTimestamp,
     user:.user.username,
     ns:.objectRef.namespace,
     pod:.objectRef.name}' audit.log
KQL · AKS audit (resource-specific table)
AKSAudit
| where ObjectRef.subresource == "exec"
| project TimeGenerated, User.username,
    ObjectRef.namespace, ObjectRef.name
CloudWatch Logs Insights · EKS cluster-admin bindings
fields @timestamp, user.username, objectRef.name
| filter objectRef.resource = "clusterrolebindings"
| filter verb = "create"
| filter requestObject.roleRef.name = "cluster-admin"
| sort @timestamp desc
kubectl · who can do what
kubectl auth can-i --list \
  --as=system:serviceaccount:prod:web
kubectl get clusterrolebindings -o wide \
  | grep cluster-admin
5

Kubernetes attack points

JuniorMidExpert

Eight places attackers aim for. Each one maps to a detection in this course.

Users, CI/CD (kubeconfig)Image registryControl planeWorker nodeAPI serverevery request is audited hereetcdcluster state, secretsSchedulerController managerkubeletnode agent, port 10250Container runtimecontainerdPod: webapp containerSA token mountedPod: privilegedhostPath /can reach the node123456781API server exposed or weak RBAC2etcd unencrypted: secrets in clear text3Kubelet 10250 open without auth4Runtime socket mounted into a pod5Privileged pod or hostPath: node escape6Service account token stolen from a pod7Leaked kubeconfig or CI credentials8Poisoned or vulnerable image pulled
6

Runtime signals inside containers

MidExpert
SignalWhy it matters
Interactive shell spawnedContainers rarely need a human shell
Package manager runs (apt, apk, yum)Immutable images should not change at runtime
Write to /bin, /usr/bin, /etcTampering or persistence
Outbound to mining pools or TorCrypto-jacking, C2
Read of service account token pathCredential theft for the API server
nsenter, mount, chroot on host pathsContainer escape attempt
Access to the cloud metadata IP 169.254.169.254Stealing node or workload cloud credentials
Falco · shell in a container (simplified)
- rule: Terminal shell in container
  desc: Shell with a terminal inside a container
  condition: >
    spawned_process and container
    and shell_procs and proc.tty != 0
  output: >
    Shell in container (user=%user.name
    container=%container.name
    image=%container.image.repository
    cmd=%proc.cmdline)
  priority: NOTICE
  tags: [container, shell, mitre_execution]
7

Container incident response

MidExpert

Deleting the pod destroys the evidence. Label it, isolate it, and capture what you need first.

Alertaudit / runtimeIdentifypod, node, imagePreservelogs, snapshotIsolatedeny-all, cordonInvestigateimage, RBAC, auditRebuildnew image, new secrets
8

Triage commands

JuniorMid
kubectl / crictl
kubectl get pods -A -o wide
kubectl describe pod <pod> -n <ns>
kubectl logs <pod> -n <ns> --previous
kubectl get events -A --sort-by=.lastTimestamp
kubectl label pod <pod> -n <ns> quarantine=true
kubectl cordon <node>
crictl ps; crictl inspect <container-id>
9

Hardening that cuts alert noise

JuniorMid

Baseline every cluster

  • Pod Security Standards: restricted for app namespaces
  • No privileged pods; read-only root filesystem; runAsNonRoot
  • Default-deny NetworkPolicies
  • Admission control (Kyverno or OPA Gatekeeper)
  • Signed images only (Sigstore cosign); scan in CI
  • Disable service account token automount where not needed
  • Check against CIS Kubernetes Benchmark (kube-bench)
10

Container alert severity guide

JuniorMid
SeverityExampleFirst move
CriticalPrivileged pod in production by an unknown identity; cluster-admin grantedRevoke binding, isolate pod, page IR
HighShell in a production pod; secrets listed across namespacesConfirm with the owner team, capture logs
MediumPackage install at runtime; new image registryTicket to app team, check the image
LowExec in a dev namespace by a known engineerLog and baseline
Try it free threatai.net/soc-gap maps your container and Kubernetes log sources to ATT&CK and shows which detections you are missing.

Key terms

Time series
A metric name plus a unique set of labels, sampled over time.
Cardinality
The number of distinct time series; it grows with every label value.
CPU throttling
The kernel pausing a container that used its CPU quota for the current period.
Working set
Memory in use minus inactive file cache; compared with the limit before an OOM kill.
Error budget
The share of requests an SLO allows to fail; burn rate is how fast it is used.
Audit log
The Kubernetes API server's record of who did what to which object.

Hands-on lab

Pro This part is included in the Pro plan. Sign in or see the plans to continue.

Knowledge check

Answer all five questions, then check your answers. Each answer comes with a short explanation.

1Why take rate() of a counter?
2A container is throttled in 27% of CPU periods. Users notice:
3Which label is safe on a metric?
4A fast-burn SLO page needs both a 1 h and a 5 min window because:
5A pod is compromised. First action?

Further reading

Put it into practice

Use these ThreatAI tools to apply what you learned to your own environment.