The CloudWatch collectd plugin is a publishing extension for collectd, an open source statistic gathering daemon. With our extension all configured collectd metrics are automatically published to CloudWatch. This plugin allows monitoring of servers and applications within and outside of EC2 instances. The plugin offers additional functionality for EC2 customers such as automatic discovery of Instance ID and AWS region.
- Download installation script, place it on the instance and execute it:
chmod u+x setup.py
sudo ./setup.py
- Follow on screen instructions
The default location of the configuration file used by collectd-cloudwatch plugin is: /opt/collectd-plugins/cloudwatch/config/plugin.conf
. The parameters in this file are optional when plugin is executed on EC2 instance. This file allows modification of the following parameters:
- credentials_path - Used to point to AWS account configuration file
- region - Manual override for region used to publish metrics
- host - Manual override for EC2 Instance ID and Host information propagated by collectd
- proxy_server_name - Manual override for proxy server name, used by plugin to connect aws cloudwatch at *.amazonaws.com.
- proxy_server_port - Manual override for proxy server port, used by plugin to connect aws cloudwatch at *.amazonaws.com.
- whitelist_pass_through - Used to enable potentially unsafe regular expressions. By default regex such as a line containing
.*
or.+
only is automatically disabled in the whitelist configuration. Setting this value to True may result in a large number of metrics being published. Before changing this parameter, read pricing information to understand how to estimate your bill. - push_asg - Used to include the Auto-Scaling Group as a dimension for all metrics (see
Adding additional dimensions to metrics
below for details) - push_constant - Used to include a Fixed dimension (see
constant_dimension_value
below) on all metrics. Useful for collating all metrics of a certain type (seeAdding additional dimensions to metrics
below for details) - constant_dimension_value - Used to specify the value for the Fixed dimension (see
Adding additional dimensions to metrics
below for details) - debug - Provides verbose logging of metrics emitted to CloudWatch
credentials_path = "/home/user/.aws/credentials"
region = "us-west-1"
host = "Server1"
proxy_server_name = "http://myproxyserver.com"
proxy_server_port = "8080"
whitelist_pass_through = False
push_asg = False
push_constant = True
constant_dimension_value = "ALL"
debug = False
We support adding both the ASG name to dimensions, as well as a "fixed dimension". Fixed dimensions are an additional value that will be added all metrics.
push_constant = True
constant_dimension_value = "MyConstantValueHere"
The above configuraton will result in all metrics being pushed with "FixedDimension" : "MyConstantValueHere"
push_constant = True
constant_dimension_value = "MyConstantValueHere"
The above configuraton will result in all metrics being pushed with "FixedDimension" : "MyConstantValueHere"
push_asg = False
The above configuration will push the AutoScaling Group name for metrics as well
The account configuration is optional for EC2 instances with IAM Role attached. By default the AWS account configuration file is expected to be stored in: /opt/collectd-plugins/cloudwatch/config/.aws/credentials
.
The following parameters can be configured in the above file:
- aws_access_key - Access Key ID for account with permissions to write to CloudWatch
- aws_secret_key - Secret Access Key for the above account
aws_access_key = valid_access_key
aws_secret_key = valid_secret_key
The CloudWatch collectd plugin allows users to select metrics to be published. This is done by adding metric names or regular expressions written in python regex syntax to the whitelist config file. The default location of this configuration is: /opt/collectd-plugins/cloudwatch/config/whitelist.conf
.
- In order to send all metrics from collectd directly to CloudWatch you can add the following rule to the whitelist.conf:
.*
- The metric names in CloudWatch are slightly different from the metric key used in the white list.
swap--swap-free
memory--memory-.*
df-.*-percent_bytes-used
- Only the swap.swap.free metric will be published from all swap metrics
- All memory metrics will be published
- The df.percent_bytes.used metric will be published for every file system reported by df plugin
Once the plugin is configured correctly, restart collectd to load new configuration.
sudo /etc/init.d/collectd restart
From now on your collectd metrics will be published to CloudWatch.
Our plugin uses collectd logfile plugin. In order to enable logging in collectd, modify the collectd.conf to contain the following section:
LoadPlugin logfile
<Plugin logfile>
LogLevel info
File "/var/log/collectd.log"
Timestamp true
PrintSeverity false
</Plugin>
The collectd log can be filtered for CloudWatch plugin events using grep:
grep "[AmazonCloudWatchPlugin]" /var/log/collectd.log
- Create your fork by clicking Fork button on top of the page.
- Download your repository:
git clone https://github.com/USER/cloudwatch-collectd-plugin.git
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'My new feature description'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request
The MIT License (MIT)
Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.