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
- 0Start here: what to monitor in a container platformJuniorMidExpert20 min · 2 exercises
- 1Metrics: the Prometheus modelJuniorMidExpert25 min · 3 exercises
- 2Containers and nodes: cgroups, throttling and memoryJuniorMidExpert20 min · 3 exercises
- 3Kubernetes state: pods, restarts and right-sizingJuniorMidExpert25 min · 3 exercises
- 4Queries and alerts that people trustJuniorMidExpert25 min · 3 exercises
- 5Logs: from container stdout to searchable eventsJuniorMidExpert25 min · 3 exercises
- 6Traces with OpenTelemetryJuniorMidExpert25 min · 3 exercises
- 7SLOs, error budgets and burn-rate alertsJuniorMidExpert25 min · 3 exercises
- 8Security monitoring: audit logs and runtimeJuniorMidExpert25 min · 3 exercises
- 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.
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.
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.
| Method | For | Signals |
|---|---|---|
| RED | services (the tracker API) | Rate, Errors, Duration |
| USE | resources (nodes, CPU, memory, disks) | Utilisation, Saturation, Errors |
| Four golden signals | user-facing systems | latency, traffic, errors, saturation |
| SLOs | deciding when to act | SLI vs target, error budget, burn rate |
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.
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 8helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install kps prometheus-community/kube-prometheus-stack -n monitoring --create-namespace
helm repo add grafana https://grafana.github.io/helm-charts
helm install loki grafana/loki -n monitoring # plus Fluent Bit, the OTel Collector and FalcoQuick check: A pod restarted at 03:10 and was replaced. Which telemetry still tells you why?
Collect off the node continuously; the pod's local state disappears with it.
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
Pull-based metrics, PromQL, alert rules.
Use it for: metrics for everything in the cluster
Integrates with: kube-prometheus-stack, Grafana
Dashboards across metrics, logs and traces.
Use it for: one place to look
Integrates with: Prometheus, Loki, Tempo
Vendor-neutral SDKs and Collector for traces, metrics, logs.
Use it for: instrumenting services
Integrates with: Tempo, Jaeger, any backend
Runtime security from kernel events.
Use it for: detecting attacks inside containers
Integrates with: Kubernetes, SIEM
Set up the lab
Goal: ~/k8smon holds the tracker with a /metrics endpoint and the data sets used in every module.
Metrics: the Prometheus model
Goal: Expose metrics, scrape them, compute rates and latency percentiles from counters and histograms, and keep cardinality under control.
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.
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.
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.
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.
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.
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.
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.
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.
Quick reference (the cheat-sheet lessons and the PDF content)
Where container telemetry comes from
Kubernetes audit logging is off by default on self-managed clusters and often partial on managed ones. Turn it on first.
Container attack chain
Docker host red flags
- Docker API on TCP 2375 with no TLS
/var/run/docker.sockmounted into a container- Containers run with
--privilegedor--pid=host - Images pulled from unknown registries
Kubernetes red flags
system:anonymousorsystem:unauthenticatedallowed- Kubelet port 10250 reachable without auth
- Default service account bound to
cluster-admin - No NetworkPolicies: every pod can reach every pod
Kubernetes audit log detections
| Use case | Audit log signal | ATT&CK |
|---|---|---|
| Shell into a pod | verb=create on pods/exec or pods/attach in production namespaces | T1609 |
| Privileged pod created | Pod spec with privileged: true, hostPID, hostNetwork or a hostPath of / | T1611 |
| Cluster-admin granted | create ClusterRoleBinding to cluster-admin | T1098 |
| Secrets harvested | list or get on secrets across namespaces by a service account | T1552.007 |
| Anonymous access | Any request with user.username=system:anonymous that succeeds | T1078 |
| Persistence workload | New DaemonSet or CronJob, especially in kube-system | T1053.007 |
| Port-forward / proxy | pods/portforward or services/proxy from an unusual user | T1090 |
| Token minting | create on serviceaccounts/token outside CI | T1528 |
| Admission control removed | delete on ValidatingWebhookConfiguration or policy objects | T1562 |
| Mass failed requests | Many 403 responses from one identity (RBAC probing) | T1613 |
Queries
Table and field names differ by platform and log pipeline. Check yours first.
jq -c 'select(.objectRef.subresource=="exec")
| {t:.requestReceivedTimestamp,
user:.user.username,
ns:.objectRef.namespace,
pod:.objectRef.name}' audit.logAKSAudit
| where ObjectRef.subresource == "exec"
| project TimeGenerated, User.username,
ObjectRef.namespace, ObjectRef.namefields @timestamp, user.username, objectRef.name
| filter objectRef.resource = "clusterrolebindings"
| filter verb = "create"
| filter requestObject.roleRef.name = "cluster-admin"
| sort @timestamp desckubectl auth can-i --list \
--as=system:serviceaccount:prod:web
kubectl get clusterrolebindings -o wide \
| grep cluster-adminKubernetes attack points
Eight places attackers aim for. Each one maps to a detection in this course.
Runtime signals inside containers
| Signal | Why it matters |
|---|---|
| Interactive shell spawned | Containers rarely need a human shell |
| Package manager runs (apt, apk, yum) | Immutable images should not change at runtime |
Write to /bin, /usr/bin, /etc | Tampering or persistence |
| Outbound to mining pools or Tor | Crypto-jacking, C2 |
| Read of service account token path | Credential theft for the API server |
nsenter, mount, chroot on host paths | Container escape attempt |
| Access to the cloud metadata IP 169.254.169.254 | Stealing node or workload cloud credentials |
- 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]Container incident response
Deleting the pod destroys the evidence. Label it, isolate it, and capture what you need first.
Triage commands
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>Hardening that cuts alert noise
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)
Container alert severity guide
| Severity | Example | First move |
|---|---|---|
| Critical | Privileged pod in production by an unknown identity; cluster-admin granted | Revoke binding, isolate pod, page IR |
| High | Shell in a production pod; secrets listed across namespaces | Confirm with the owner team, capture logs |
| Medium | Package install at runtime; new image registry | Ticket to app team, check the image |
| Low | Exec in a dev namespace by a known engineer | Log and baseline |
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
Knowledge check
Answer all five questions, then check your answers. Each answer comes with a short explanation.
Further reading
- Kubernetes: observability and logging kubernetes.io
- Kubernetes auditing kubernetes.io
- Prometheus documentation prometheus.io
- OpenTelemetry Collector opentelemetry.io
- Google SRE workbook: alerting on SLOs sre.google
- Falco rules falco.org
Put it into practice
Use these ThreatAI tools to apply what you learned to your own environment.