As we all know, monitoring EC2 instance is a vital part of managing and administering AWS resource, with the benefit of AWS CloudWatch, it allows the user to have visibility into how our resources are behaving and provides realtime dashboards to get valuable information. Some of the main Benefits of CloudWatch metrics are:
for our recommended levels of CPU usage, or storage usage, and alerts us when alarms break.
· Generates alert on CloudWatch so that the system is proactively monitoring to pre-empt possible issue,
· To make your application more secure with constant security detect,
· It can help you monitor the resultant performance and cost of your application,
· Troubleshooting and recommendation for future and how to avoid the existing errors.
One thing you may notice is that from the list of Instance Metric within AWS Documentation, any metric related to memory consumption is not provided by default, this is a crucial piece of information for system administrator to review especially with database running. This is possibly due to the fact that metrics provided by AWS are collected at the hypervisor level comparing to memory metrics (like disk IOPS) is from the OS level, hence it is a custom metric that you have to periodically push toCloudWatch.
To obtain memory metric, you can install a custom monitoring script which will provide you statistics including memory, swap, and disk space utilization. The high-level steps are:
*applicable for Amazon Linux/Ubuntu/ SUSE/Red Hat instance
1. Ensure script have permission to call CloudWatch action with the associate instance IAM role,
2. Connect to the instance and Install theRequire Packages,
3. Install Monitoring Script “CloudWatchMonitoringScripts-1.2.2.zip”,
4. Run the script with your desired option, e.g. to get utilization statistics for the last 12 hours, run the command:
5. Following is a snippet of the output:
After you successfully run the mon-put-instance-data.pl script, you can view your custom metrics in the Amazon CloudWatch console.
1. Run mon-put-instance-data.pl as described previously.
2. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.
3. Choose View Metrics.
4. For Viewing, your custom metrics posted by the script are displayed with the prefix System/Linux.
With the ability to monitor Memory consumption, you will obtain an extensive review of your instance without the need to establish a manual connection, this result in more efficient management in time saving manner and even more precise recommendations.
To find more in detail and where to download the script, kindly visit Configure Monitor memory /diskmetric EC2 Linux .
You can also configure other custom CloudWatchmetric explained in here.