KCNA Monitoring and Logging 5 — Questions and Answers
Question 1: When using Grafana with Loki as a data source, which query language is used to filter and search logs?
- PromQL
- LogQL (Correct answer)
- SQL
- Lucene
Correct answer: LogQL
LogQL is Loki's query language, inspired by PromQL, used to filter log streams by labels and search log content using line filters.
Question 2: What is the primary purpose of cAdvisor in a Kubernetes node?
- Schedule pods onto nodes
- Collect resource usage and performance metrics for running containers (Correct answer)
- Manage container networking
- Pull container images from registries
Correct answer: Collect resource usage and performance metrics for running containers
cAdvisor (Container Advisor) is embedded in the kubelet and collects CPU, memory, filesystem, and network usage metrics for containers running on the node.
Question 3: What does 'cardinality' mean in the context of Prometheus metrics, and why does high cardinality matter?
- The number of Prometheus targets being scraped
- The total number of unique label value combinations for a metric (Correct answer)
- The frequency at which metrics are scraped
- The duration metrics are retained in storage
Correct answer: The total number of unique label value combinations for a metric
Cardinality is the number of unique time series created by all combinations of label values; high cardinality can exhaust Prometheus memory and degrade performance.
Question 4: In Kubernetes, what happens to a pod's logs after the pod is deleted?
- Logs are automatically backed up to object storage
- Logs are permanently lost unless a log aggregation system collected them (Correct answer)
- Logs are transferred to the replacement pod
- Logs are retained in etcd for 30 days
Correct answer: Logs are permanently lost unless a log aggregation system collected them
When a pod is deleted, its log files on the node are garbage collected, so logs must be shipped to an external system before deletion to be retained.
Question 5: Which OpenTelemetry component acts as a central agent that receives, processes, and exports telemetry data from multiple sources?
- OTel SDK
- OTel Collector (Correct answer)
- OTel Instrumentation Library
- OTel Propagator
Correct answer: OTel Collector
The OpenTelemetry Collector is a vendor-agnostic proxy that receives telemetry from applications, processes it (filter, transform, batch), and exports it to backends.
Question 6: What is a Prometheus 'exporter' and when would you use one?
- A tool to export Prometheus data to Grafana
- An adapter that exposes metrics from third-party systems in Prometheus format (Correct answer)
- A component that exports alert data to AlertManager
- A tool that migrates metrics to long-term storage
Correct answer: An adapter that exposes metrics from third-party systems in Prometheus format
A Prometheus exporter is a bridge that converts metrics from systems that don't natively expose Prometheus format (e.g., MySQL, Redis, HAProxy) into the /metrics endpoint format.
Question 7: Which Kubernetes feature allows you to define structured log output format (JSON) at the kubelet level to improve log parsability?
- Log format flag --logging-format=json on kubelet (Correct answer)
- PodSpec.logFormat field
- ConfigMap kube-system/kubelet-config log-format key
- Annotation logging.kubernetes.io/format on each pod
Correct answer: Log format flag --logging-format=json on kubelet
The kubelet supports the --logging-format=json flag (or equivalent config) to emit structured JSON logs, making them easier to parse and index by log aggregators.
When using Grafana with Loki as a data source, which query language is used to filter and search logs?