CloudwatchMetrics
CloudwatchMetrics
is a Ruby gem for writing custom metrics to AWS Cloudwatch.
Installation
Add this line to your application's Gemfile:
gem 'cloudwatch-metrics'
And then execute:
bundle install
To create the initializer:
rails generate cloudwatch_metrics:initializer
The initializer contains descriptions for all available options. More detailed descriptions are available in the user guide, linked below. The only option you must provide a value for is namespace
.
Usage
See How To: Publish Custom Metrics to CloudWatch for the user guide.
Local development
By default, CloudWatchMetrics
only publishes to Cloudwatch in the production environment. In other environments it will write to the configured logger. These settings can be changed in the initializer.
AWS Credentials
See HOWTO Assume AWS role for info about setting up AWS credential locally. You can read more about AWS SDK configuration in the AWS docs.
The short version: Create a file ~/.aws/config
and add your access keys there:
[default]
aws_access_key_id = $AWS_ACCESS_KEY_ID
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY
You'll also want an ~/.aws/config
file to set the default region
[default]
region = us-west-2
output = json
Changing this gem
Development
Run bundle install
to update gemlock file
Run rake
to run tests
Deploy new gem
If you make changes to this gem you need to do a few things to make those updates available to clients.
Prerequisites: You will need an account on rubygems.org and you will need to be added as an owner of this gem. Talk to Seth for this. (Managing Owners)
- Bump the version in
lib/cloudwatch_metrics/version.rb
- Build the updated gem with
gem build cloudwatch_metrics.gemspec
- Push the updated to gem to rubygems with
gem push ./cloudwatch-metrics-[VERSION].gem
When the change has been published clients can update to the latest version with bundle update cloudwatch-metrics
.