Skip to content

Observability: KCSA practice questions

Observability is how operators see what a cluster and its workloads are doing, and in security work it is how unusual behavior gets noticed. Three signal types matter here: logs, metrics and events, each with its own path through the cluster.

By Ibrahim Yesilay · Published · Updated

Independent community practice, not affiliated with or endorsed by CNCF or The Linux Foundation.

What Observability covers in KCSA

Observability is how operators see what a cluster and its workloads are doing, and in security work it is how unusual behavior gets noticed. Three signal types matter here: logs, metrics and events, each with its own path through the cluster.

Container logs come from what applications write to standard output and standard error. The kubelet and container runtime capture these streams on the node and handle rotation, and kubectl logs reads them; -c selects one container in a multi-container Pod and --previous shows output from the previous instance of a crashed container. Node-local logs disappear with the node, so cluster-level logging ships them elsewhere. The recommended pattern is a node-level logging agent run as a DaemonSet, which reads every container's log files on its node and pushes them to a backend. A sidecar container with its own logging agent is an alternative, but its logs are not visible through kubectl logs.

Resource metrics follow a separate pipeline. The metrics-server collects CPU and memory usage from the kubelets on each node and exposes them through the Metrics API, which the HorizontalPodAutoscaler and VerticalPodAutoscaler consume. kubectl top pod and kubectl top node read the same API, which is why metrics-server, a cluster add-on, must be installed for them to work. The HorizontalPodAutoscaler uses these figures to change the replica count of a Deployment or StatefulSet, for example to keep average CPU utilization near a target.

For richer, longer-lived monitoring, Prometheus is the common choice. It is an open-source monitoring and alerting toolkit that stores metrics as time series identified by a metric name and key-value labels, queries them with PromQL, and collects them by pulling over HTTP from targets found through service discovery or static configuration. Short-lived jobs can push through an intermediary gateway. Grafana is the usual visualization layer and connects to Prometheus as a data source.

Day-to-day inspection uses kubectl. kubectl get nodes lists the registered nodes, kubectl describe shows an object's configuration, status and recent events, kubectl get pod with -o yaml prints the full stored definition, and kubectl events lists cluster events for a namespace, all namespaces or a single resource.

Security monitoring builds on the same signals: API server audit logs record who did what through the API, while container logs and metrics show what workloads did. Logs kept only on a node are lost with that node, which is why cluster-level collection matters for investigations.

Key points

  • kubectl top depends on metrics-server and the Metrics API.
  • Logs written to stdout and stderr are what kubectl logs returns.
  • Logs from a sidecar logging agent are not visible through kubectl logs.
  • Prometheus pulls metrics over HTTP and is queried with PromQL; Grafana uses it as a data source.

Three sample questions

19 KCSA questions on Observability, 19 with explanations. How practice works

Question 1

What is the primary purpose of Grafana in IT operations?
  1. A.Managing code version control
  2. B.Automating continuous integration pipelines
  3. C.Visualizing and monitoring metrics through dashboards
  4. D.Enforcing network security policies
  5. E.Managing user identities and access

Correct answer: C

Grafana is an open-source platform used primarily for creating dashboards that visualize metrics and monitoring data from various sources. It helps IT teams observe system performance and troubleshoot issues. It is not used for version control, continuous integration, network security enforcement, or identity management.

Sources: Grafana Labs - What is Grafana?, The New Stack - Introduction to Grafana

Question 2

Which tool serves as a data source for visualizing Kubernetes cluster metrics in Grafana?
  1. A.Prometheus
  2. B.Elasticsearch
  3. C.Kibana
  4. D.Fluentd
  5. E.Logstash

Correct answer: A

Prometheus is a robust monitoring and alerting toolkit that collects metrics from Kubernetes clusters. These metrics can be integrated into Grafana as a data source to create dashboards for visualization. While Grafana handles the visualization, Prometheus provides the necessary data. Other options like Elasticsearch, Kibana, Fluentd, and Logstash are primarily used for logging and log analysis, not for collecting or serving metrics directly.

Sources: Kubernetes Documentation - Monitoring with Prometheus, Grafana Documentation - Prometheus Integration

Question 3

Which kubectl command is used to retrieve the logs of a pod named 'my-pod'?
  1. A.kubectl get logs my-pod
  2. B.kubectl describe my-pod
  3. C.kubectl logs my-pod
  4. D.kubectl status my-pod
  5. E.kubectl inspect my-pod

Correct answer: C

The correct command to view the logs of a pod named 'my-pod' is 'kubectl logs my-pod'. This command fetches the standard output and error logs from the pod's containers. 'kubectl describe' provides detailed resource information but not logs. The other commands are invalid or do not exist.

Sources: Kubernetes Official Documentation - Viewing Logs, Kubernetes kubectl Reference - logs

Practice this topic

Focus mode keeps every question on Observability until you leave it. 10 free guest answers, then a free account; no credit card.

Or open KCSA practice across all topics.

Sources

The explanation above was checked against these official documents.