A SysOps Administrator has deployed Amazon CloudWatch Container Insights on an Amazon EKS cluster running on Amazon EC2 worker nodes by running the CloudWatch agent as a DaemonSet. The Administrator notes that while the agent's diagnostic logs are successfully being written to CloudWatch, no Container Insights performance metrics (such as cluster, node, or pod CPU utilization) are appearing in the CloudWatch console. What is the most likely cause of this issue?
- ADetailed monitoring has not been enabled on the EC2 instances hosting the EKS worker nodes, which prevents CloudWatch from collecting container-level metrics.
- BThe log retention period for the `/aws/containerinsights/<cluster-name>/performance` log group has been configured to expire immediately, preventing CloudWatch from extracting metrics.
- The ServiceAccount used by the CloudWatch agent DaemonSet is not bound to the required ClusterRole, preventing the agent from querying the Kubernetes API for container and node metrics.Answer
- DAn Amazon EventBridge rule is missing to route performance log events from the CloudWatch Logs group to the CloudWatch metrics engine.
Answer
The ServiceAccount used by the CloudWatch agent DaemonSet is not bound to the required ClusterRole, preventing the agent from querying the Kubernetes API for container and node metrics.
To retrieve the performance metrics for Container Insights, the CloudWatch agent running in EKS needs read permissions to the Kubernetes API and Kubelet stats endpoint. This is achieved by creating a ServiceAccount for the DaemonSet pods and linking it to a ClusterRole that has get, list, and watch permissions on resources like pods and nodes. The link must be established using a ClusterRoleBinding. If this binding is missing, the agent cannot access the API, preventing it from writing performance events, which results in empty Container Insights metrics.
Step-by-Step Solution
Key Concept
CloudWatch Container Insights EKS RBAC Requirements
Estimated Time:2m 0s