- Newest
- Most votes
- Most comments
You have several options to monitor memory usage for your EKS pods and nodes, even without direct access to the underlying EC2 instances.
The most comprehensive solution is to enable Container Insights, which is specifically designed for this purpose. Container Insights collects, aggregates, and summarizes metrics and logs from your containerized applications and microservices. Once enabled, you can view detailed metrics like pod_cpu_utilization and pod_memory_utilization directly in the CloudWatch console.
To enable Container Insights for your EKS cluster, you can use the AWS CLI:
aws eks update-cluster-config --name <cluster-name> --logging '{"clusterLogging":[{"types":["api","audit","authenticator","controllerManager","scheduler"],"enabled":true}]}'
For more immediate visibility, you can use kubectl commands:
kubectl top pods- Shows current CPU and memory usage for all podskubectl top nodes- Displays resource usage across your nodeskubectl top pod <pod-name> --namespace <namespace> --containers- Provides container-level resource metricskubectl describe pod <pod>- Gives detailed information about a specific pod, including resource requests and limits
To analyze OOMKill events specifically, you can run queries in CloudWatch Logs Insights. For example, to check memory utilization:
stats avg(MemoryUtilized) by bin (30m) as period, TaskDefinitionFamily, TaskDefinitionRevision
| filter Type = "Task" | sort period desc, TaskDefinitionFamily | limit 10
You can also consider using the Kubernetes Dashboard, which provides a web-based UI with information about resource usage at cluster, node, and pod levels. This gives you consolidated visibility into your Kubernetes environment with resource usage breakdowns.
For a more complete monitoring solution, consider setting up CloudWatch alarms for key metrics like memory usage and configure notifications using Amazon SNS to alert you before pods experience OOMKill events.
Sources
How to monitor high resource usage in Amazon EKS tasks and services | AWS re:Post
Metrics for Amazon EKS and Kubernetes - AWS Prescriptive Guidance
Monitor high resource usage in ECS tasks and services | AWS re:Post
Expenditure awareness - Amazon EKS
Logging and monitoring on Amazon EKS - AWS Prescriptive Guidance
answered a year ago
Relevant content
asked a year ago
- AWS OFFICIALUpdated 3 years ago
