8. Alarms can take actions:
• Send message through SNS
• Trigger autoscaling
9. Even Better
You can create your own metrics
So you can trigger your own events
10. Terminology
Metric - a time-ordered set of data points
Dimension - A name/value pair that helps you to
uniquely identify a metric. e.g.: EC2 InstanceID
NameSpace - container
Statistic Set - Aggregated set of data points (as
often as once per minute)
11. Example from the AWS tutorial:
Pick an arbitrary set of data points
• Hour one: 87, 51, 125, 235
• Hour two: 121, 113, 189, 65, 89
• Hour three: 100, 47, 133, 98, 100, 328
12. Hour 1 - Individual points
Hour Raw Data
1 87
1 51
1 125
1 235
13. Hours 2&3 - Stat Sets
Four predefined keys: Sum, Minimum, Maximum, and SampleCount
Sample
Hour Raw Data Sum Min Max
Count
2 121,113,189,65,89 577 65 189 5
3 100,47,133,98,100,328 806 47 328 6
14. Push with CLI
# For Hour 1
# The unit of measurement is optional
mon-put-data -m RequestLatency -n "Nathan" -t 2012-01-24T11:00:00 -v 87 -u Milliseconds
mon-put-data -m RequestLatency -n "Nathan" -t 2012-01-24T11:00:00 -v 51 -u Milliseconds
mon-put-data -m RequestLatency -n "Nathan" -t 2012-01-24T11:00:00 -v 125 -u Milliseconds
mon-put-data -m RequestLatency -n "Nathan" -t 2012-01-24T11:00:00 -v 235 -u Milliseconds
# For Hour 2
mon-put-data -m RequestLatency -n "Nathan" -t 2012-01-24T12:00:00 -s "Sum=577,Minimum=47,Maximum=189,SampleCount=5" -u Milliseconds
# For Hour 3
# If no timestamp is provided, it defaults to the current time
mon-put-data -m RequestLatency -n "Nathan" -s "Sum=806,Minimum=47,Maximum=328,SampleCount=6" -u Milliseconds
15. When you use the mon-put-data command, you must use a
date range within the past two weeks. There is currently no
function to delete data points. Amazon CloudWatch
automatically deletes data points with a timestamp more than
two weeks old.
Can include --dimensions "x=y,u=v" in both puts and gets
16. Retrieve Stats with CLI
MacBook-Pro:~ user$ mon-get-stats -n Nathan -m RequestLatency -s "Average" --start-time 2012-01-24T11:00:00 --period 3600 --headers
Time Average Unit
2012-01-24 11:00:00 106.0 Milliseconds
2012-01-24 12:00:00 122.5 Milliseconds
18. Quirks of the View
One drawback to CloudWatch is that can be
difficult to understand the graphs
19. It’ll report what you ask for - Literally
E.g. If you leave "Sum" selected and select "Healthy Host Count",
it adds up all the data points supplied during the period selected.
So instead of "10" you get "2500".
21. Have to experiment with different
view parameters to get an
accurate picture
E.g.: ELB Response Codes - the data points don't represent numbers of coded responses during a
period. Each one represents one instance of a code received. So to see the number of 2xx response
codes for a period, you need to select the "Sum" statistic
22. If there aren't enough data-points, it
won't draw the connecting lines.
23. Amazon CloudWatch does not aggregate
data across Regions
List of available endpoints and regions:
http://docs.amazonwebservices.com/general/latest/gr/rande.html?r=5025
25. Docs and Tools
Documentation:
http://aws.amazon.com/documentation/cloudwatch/
CloudWatch CLI tools:
Setup Page:
http://docs.amazonwebservices.com/AmazonCloudWatch/latest/GettingStartedGuide/SetupCLI.html
Set JAVA_HOME on OSX Lion:
http://steveswinsburg.wordpress.com/2011/07/22/java_home-on-os-x-lion/
Reference for AWS Service Metrics
http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html
Great How-To with Python and Boto:
http://loggly.com/blog/2011/05/send-custom-metrics-to-cloudwatchs-api/