Package: cloudwatch-to-graphite
Cloudwatch-to-Graphite (leadbutt) is a small utility to take metrics from
CloudWatch to Graphite.InstallationInstall using pip:pip install cloudwatch-to-graphiteConfiguringbotoCloudwatch-to-Graphite usesboto, so make sure to follow itsconfiguration
instructions. The easiest way to do this is to set up theAWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables.UsageConfiguration FilesIf you have a simple setup, the easiest way to get started is to set up a
config.yaml. You can copy the included config.yaml.example. Then just run:leadbuttIf you have several configs you want to switch between, you can specify a
custom configuration file:leadbutt --config-file=production.yaml -n 20You can even generate configs on the fly and send them in via stdin by setting
the config file to ‘-‘:generate_config_from_inventory | leadbutt --config-file=-There’s a helper to generate configuration files calledplumbum.  Use it like:plumbum [-r REGION] [-f FILTER] [--token TOKEN] template namespaceNamespace is the CloudWatch namespace for the resources of interest; for exampleAWS/RDS.
The template is a Jinja2 template. You can add arbitrary replacement tokens, eg{{ replace_me }}, and then
pass in values on the CLI via--token. For example, if you called:plumbum --token replace_me='hello, world' sample_templates/rds.yml.j2 AWS/RDSYou would get all instances of{{ replace_me }}in the templace replaced withhello, world.FiltersYou can pass simplekey=valuefilters in toplumbum; be aware of the limitations:the filters run against whatever the AWS API has returned; if you have a lot of objects of whatever type, expect the API request to take a while.they work only against object attributes and tags returned by the API. For example, RDS and ELB objects can be tagged, but as getting the tags is a per-object subrequest;plumbumdoes not do those, so you can only filter on the object attributes.Example:plumbum-fName=my-dev-instancesample_templates/ec2.yml.j2 ec2Sending Data to GraphiteIf your graphite server is at graphite.local, you can send metrics by chaining
with netcat:leadbutt | nc -q0 graphite.local 2003Or if you want to use UDP:leadbutt | nc -uw0 graphite.local 2003If you need to namespace your metrics for a hosted Graphite provider, you could
provide a custom formatter, but the easiest way is to just run the output
through awk:leadbutt | \
  awk -v namespace="$HOSTEDGRAPHITE_APIKEY" '{print namespace"."$0}' | \
  nc -uw0 my-graphite-provider.xxx 2003Customizing Your Graphite Metric NamesSet theFormatteroption to set the template used to generate Graphite
metric names. I wasn’t sure what should be default, so I copiedcloudwatch2graphite’s. Here’s what it looks like:cloudwatch.%(Namespace)s.%(dimension)s.%(MetricName)s.%(statistic)s.%(Unit)sTitleCased variables come directly from the YAML configuration, while lowercase
variables are derived:statistic– the current statistic sinceStatisticscan be a listdimension– the dimension value, e.g. “i-r0b0t” or “my-load-balancer”The format string is Python’s%-style.config.yamlWhat metrics are pulled is in a YAML configuration file. See the example
config.yaml.example for an idea of what you can do.DevelopingSee: :Contributing.Useful ReferencesCloudWatch Referenceboto CloudWatch docsPrior ArtCloudwatch-to-Graphite was inspired by edasque’scloudwatch2graphite. I was
looking to expand it, but I wanted to useboto.