Reputation: 845
I need to create a AWS Lambda function in JAVA to print the EC2 instance's CPU Utilisation. How to get the CPU utilization of EC2 instance using AWS JAVA SDK.
Upvotes: 2
Views: 2067
Reputation: 270274
Amazon CloudWatch maintains metrics about every Amazon EC2 instance, including CPU Utilization.
By default, metrics are collected at 5-minute intervals at no charge. You can enable detailed monitoring for an instance, which will collect metrics at 1-minute intervals. Additional charges apply.
You can obtain the metrics via a call to Amazon CloudWatch. Use the getMetricData()
function.
Note that you actually request a calculated value over a period of time, such as "Average CPU for the previous 5 minutes".
Upvotes: 3