Skip to main content

Helper for pushing AWS CloudWatch metrics to Graphite

Project description

https://travis-ci.org/crccheck/cloudwatch-to-graphite.svg

Cloudwatch-to-Graphite (leadbutt) is a small utility to take metrics from CloudWatch to Graphite.

Installation

Install using pip:

pip install cloudwatch-to-graphite

Configuring boto

Cloudwatch-to-Graphite uses boto, so make sure to follow its configuration instructions. The easiest way to do this is to set up the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables.

Usage

Configuration Files

If 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:

leadbutt

If you have several configs you want to switch between, you can specify a custom configuration file:

leadbutt --config-file=production.yaml -n 20

You 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 called plumbum. For now, you’ll have to read the source of plumbum.py for usage.

Sending Data to Graphite

If your graphite server is at graphite.local, you can send metrics by chaining with netcat:

leadbutt | nc -q0 graphite.local 2003

Or if you want to use UDP:

leadbutt | nc -uw0 graphite.local 2003

If 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 2003

Customizing Your Graphite Metric Names

Set the Formatter option to set the template used to generate Graphite metric names. I wasn’t sure what should be default, so I copied cloudwatch2graphite’s. Here’s what it looks like:

cloudwatch.%(Namespace)s.%(dimension)s.%(MetricName)s.%(statistic)s.%(Unit)s

TitleCased variables come directly from the YAML configuration, while lowercase variables are derived:

  • statistic – the current statistic since Statistics can be a list

  • dimension – the dimension value, e.g. “i-r0b0t” or “my-load-balancer”

The format string is Python’s %-style.

config.yaml

What metrics are pulled is in a YAML configuration file. See the example config.yaml.example for an idea of what you can do.

Developing

Install requirements:

pip install -r requirements.txt

Running test suite:

make test

Verifying tests run over all supported Python versions:

tox

Useful References

Prior Art

Cloudwatch-to-Graphite was inspired by edasque’s cloudwatch2graphite. I was looking to expand it, but I wanted to use boto.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cloudwatch-to-graphite-0.8.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

cloudwatch_to_graphite-0.8.1-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file cloudwatch-to-graphite-0.8.1.tar.gz.

File metadata

File hashes

Hashes for cloudwatch-to-graphite-0.8.1.tar.gz
Algorithm Hash digest
SHA256 6e6667090504950fce0f196010a3d8758bbb8b32f6bbf7b2a719fd08cfdb9b02
MD5 b659907b188362e4f09c555e8cbd7f4f
BLAKE2b-256 77286d5adf1d6c9c28165b4152cfc3e16d1182bacad91215a285381bb9364d10

See more details on using hashes here.

File details

Details for the file cloudwatch_to_graphite-0.8.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for cloudwatch_to_graphite-0.8.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 556db842b3a8cb95f221297f4e9b1ee8dcecf5ef4b630ddde89d650028d01323
MD5 15dafc37ca1224ad315eebd3acb6f92e
BLAKE2b-256 83de20bab5ec2c6f3c5e3203fbe6fe853304f32a757991b08ef727ce2e721d89

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page