![]() ![]() I came across a simple python script, from Loggly, that signs the passed parameters, and can easily be setup to put the Cloudwatch metrics. However, even an SDK seems to be overkill for one command. This can be accomplished using any of the available SDKs (e.g. The project ‘ aws-missing-tools’, hosted on Google Code has a few more scripts, similar to the one above, for gathering other metrics.ĭue to the poor performance of the AWS CLI tools, it is far more efficient to call the API directly. ![]() Set it up to run every 5 minutes with crontab -e */5 * * * * /path/to/script.sh To use the script, make it executable: chmod +x /path/to/script.sh It should also be mentioned that the bash math used above will only yield integer results.As a personal preference, I have used curl instead of wget.The paths I have used, above, are for Amazon’s Linux AMI.AWS_CLOUDWATCH_HOME/bin contains the cloudwatch command line tools.The script takes the number from the ‘ -/+ buffers/cache‘ row under the ‘ free‘ column, as a percent of ‘ total‘ (under the ‘ Mem‘ row), and sets up one metric ( UsedMemoryPercent), in the namespace ‘ System/Linux’, with a single dimension ( InstanceID). Mon-put-data -metric-name "UsedMemoryPercent" -namespace "System/Linux" -dimensions "InstanceID=$instanceid" -value "$memused" -unit "Percent" Memfree=`free -m | grep 'buffers/cache' | tr -s ' ' | cut -d ' ' -f 4` Memtotal=`free -m | grep 'Mem' | tr -s ' ' | cut -d ' ' -f 2` I’ll use the example of used memory throughout this post, since it is a fairly common use case (and it can be easily adapted for other metrics).Īmazon has posted a bash script to get us started, modified slightly below: #!/bin/bashĮxport AWS_CLOUDWATCH_HOME=/opt/aws/apitools/monĮxport EC2_PRIVATE_KEY=/path/to/pk-XXXXXXXXXXXXXXXXXXXXXXXXXX.pemĮxport EC2_CERT=/path/to/cert-XXXXXXXXXXXXXXXXXXXXXXXXXX.pemĮxport PATH=$AWS_CLOUDWATCH_HOME/bin:$PATH None the less, they are easy to use, and a good starting point (we’ll look at an alternate approach later). It is worth noting, here, that the AWS command line tools are Java based, and have to load Java before they can do anything, which makes them quite slow. It might take a few minutes for the results to initially show up on Cloudwatch, but from my experience it is usually only a few seconds. Pass the command a metric name, namespace, credentials, and a value and you are good to go. Note: Metrics differing in any name, namespace, or dimensions (case sensitive) are classified as different metrics. [-statisticValues "SampleCount=value, Sum=value, metric-name value -namespace value [-dimensions ![]() This is available as one of the CLI tools for AWS, mon-put-data: mon-put-data Metrics are automatically created when data is added to them.Ĭustom metrics are created using the ‘PutMetricData’ request. It is worth mentioning that you cannot delete a metric – any data saved is retained for 2 weeks. ![]() EBS volumes, SNS, etc.)Ĭloudwatch metrics do not have to be precreated, nor is it necessary to allocate space for them. Additional metrics are made available for other services (e.g. Setting up a custom Cloudwatch metricĪutoscaling uses Cloudwatch alarms to trigger events, in order to use it, we therefore need a functioning Cloudwatch metric and alarm.Ĭloudwatch’s basic monitoring is in 5 minute increments and measures a number of parameters that are independent of the operating system and user data, including CPU utilization, disk I/O (in operations and bytes) and network usage. In this article, we look at how you can trigger a change in the number of running instances using a custom Cloudwatch metric – including the setup of said metric, and a brief look at the interactions between the various autoscaling commands used. In essence, this allows you to vary the number of (related) running instances according to some metric that is being tracked. One of the ways that Amazon provides for this is through autoscaling. One of the appeals of cloud computing is the idea of using what you need when you need. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |