Search code examples
amazon-web-servicesamazon-ec2cloudcpuutilization

CPU utilization usage check in EC2 for the past time usage


In AWS My CPU Utilization goes from 2% to 90% for 10 minutes how to get the usage details for the past usage time in AWS EC2 instance?


Solution

  • To get the cpu utilization of the instance, we need to have the ID of the instance. We can get the instance ID using the AWS Management Console or the describe-instances command.

    By default, basic monitoring is enabled, but we can enable detailed monitoring for the Ec2 instance.

    Once we have the instance Id, we can get the cpu stats by using the command

    aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization  --period 3600 \
    --statistics Maximum --dimensions Name=InstanceId,Value=i-EC2_INSTANCE_ID \
    --start-time 2022-10-18T23:18:00 --end-time 2022-10-19T23:18:00
    

    Alternatively, we can view the graphs on CloudWatch. Please refer to the following article for complete details.