PCA (Prometheus Certified Associate) sample exam question with answer 522

Question:
Which of the following PromQL expressions will return the average memory usage of all running containers in a Kubernetes cluster? (Select all that apply)

  1. sum(container_memory_usage_bytes) by (pod_name) / count(container_memory_usage_bytes) by (pod_name)
  2. sum(container_memory_usage_bytes) by (container_name) / count(container_memory_usage_bytes) by (container_name)
  3. sum(container_memory_usage_bytes) by (namespace) / count(container_memory_usage_bytes) by (namespace)
  4. sum(container_memory_usage_bytes) / count(container_memory_usage_bytes)
Answer:
A - is correct. It calculates the average memory usage by summing up memory usage for each container in a pod and dividing it by the number of containers in that pod
B - is correct. It calculates the average memory usage by summing up memory usage for each container across all pods and dividing it by the total number of containers
C - is incorrect. It calculates the average memory usage by summing up memory usage for each namespace and dividing it by the number of pods in that namespace, which may not give an accurate representation of container memory usage
D - is incorrect. It calculates the overall average memory usage across all containers and pods, which may not be useful in a multi-container environment