Difference between revisions of "Heat/Using-CloudWatch"
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | Note: the current cloud watch implementation is incomplete (it only sufficient for [HA](https://github.com/heat-api/heat/wiki/Using-HA)). But should be easy to make more generally useful. | + | Note: the current cloud watch implementation is incomplete (it's only sufficient for [HA](https://github.com/heat-api/heat/wiki/Using-HA)). But should be easy to make more generally useful. |
To use cloud watch you need the following in your template: | To use cloud watch you need the following in your template: | ||
Line 25: | Line 25: | ||
/opt/aws/bin/cfn-push-stats --watch [[MyOwnAlarm]] [other args] | /opt/aws/bin/cfn-push-stats --watch [[MyOwnAlarm]] [other args] | ||
− | To see this all together look at the [ | + | To see this all together look at the [https://github.com/heat-api/heat/blob/master/templates/WordPress_Single_Instance_With_HA.template HA template] |
== [[CloudWatch]] API == | == [[CloudWatch]] API == |
Revision as of 00:54, 17 February 2013
Note: the current cloud watch implementation is incomplete (it's only sufficient for [HA](https://github.com/heat-api/heat/wiki/Using-HA)). But should be easy to make more generally useful.
To use cloud watch you need the following in your template:
"MyOwnAlarm": { "Type": "AWS::CloudWatch::Alarm", "Properties": { "AlarmDescription": "Restart the WikiDatabase if httpd fails > 3 times in 10 minutes", "MetricName": "ServiceFailure", "Namespace": "system/linux", "Statistic": "SampleCount", "Period": "300", "EvaluationPeriods": "1", "Threshold": "2", "AlarmActions": [ { "Ref": "WebServerRestartPolicy" } ], "ComparisonOperator": "GreaterThanThreshold" }
Note: Currently the only Action that is supported is HEAT::HA::Restarter
Then you need to call this from in your vm: /opt/aws/bin/cfn-push-stats --watch MyOwnAlarm [other args]
To see this all together look at the HA template
CloudWatch API
An AWS-compatible API to the heat CloudWatch alarms and metrics is in-progress. Not all AWS actions are supported (yet), but you can do the following:
- List Alarms
- List Metrics (related to alarms only, generic Metric datapoints not yet supported)
- Create Metric Datapoints (similar to current cfn-push-stats functionality but authenticated)
- Set Alarm state (temporarily, useful for testing alarm actions)
Status of API actions as they are implemented will be tracked in the API roadmap page(https://github.com/heat-api/heat/wiki/Roadmap-Feature:-cloudwatch-api)
You can use the Cloudwatch API by doing the following:
heat-api-cloudwatch -d & tail -f /var/log/heat/api-cloudwatch.log
Note that it is not currently necessary to run heat-api-cloudwatch for HA and autoscaling to work correctly - instances still report Cloudwatch metric data via the metadata server (for the time being at least..)
CloudWatch Client "**heat-watch**"
A client has been created to demonstrate the CloudWatch API - it is **heat-watch**
Usage examples:
List Alarms:
heat-watch describe
List Metrics Datapoints:
heat-watch metric-list
Create Metric Datapoints:
heat-watch metric-put-data HttpFailureAlarm system/linux ServiceFailure Count 1
Set Alarm state:
heat-watch -d set-state HttpFailureAlarm ALARM