How to do it...

  1. On the instance, run the following AWS CLI command:
       aws cloudwatch put-metric-data  
--metric-name MemoryUsagePercent
--namespace CustomMetrics
--dimensions InstanceId=`curl -s
http://169.254.169.254/latest/meta-data/instance-id`
--unit Percent
--value `free | grep Mem | awk '{print $3/$2 * 100.0}'`
  1. Go to the CloudWatch console, and navigate to the Metrics dashboard. Your metric will appear under the namespace CustomMetrics, InstanceId, and the unique ID for the instance, with the metric name MemoryUsagePercent.
It can take up to 15 minutes for a custom metric to appear in the CloudWatch dashboard (although it usually takes less). Even for the built-in metrics, it may take a minute or two for the metric data to appear in the console.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset