Skip to content
This repository has been archived by the owner on Sep 28, 2023. It is now read-only.

optimizely/chef_opentsdb_handler

Repository files navigation

opentsdb_handler Cookbook

This cookbook sets up a handler that reports to OpenTSDB at the end of a chef run

Requirements

The only requirement is the chef_handler cookbook

Attributes

Key Type Description Default
['opentsdb_handler']['metrics'] Hash this is where each metric to be sent is defined as { unique_name => metric_hash } {}
['opentsdb_handler']['metric'][unique_name]['name'] String Metric name None
['opentsdb_handler']['metrics'][unique_name]['value'] Hash Value of metric None
['opentsdb_handler']['metrics'][unique_name]['tags'] Hash Key => Value hash of tags for the metric. {'hostname' => Socket.gethostname}(IN HANDLER SCRIPT)
['opentsdb_handler'][handler_name]['run_status_tag'] Boolean Will add run_status=0|1 (success, failure respectively) tag if true false
['opentsdb_handler']['run_status']['elapsed_time'|'start_time'|'end_time'] Boolean Will send a metric of the chef.elapsed_time (or start_time or end_time) if true. Change tags on ['handlers']['elapsed_time']['tags'] false
['opentsdb_handler']['hostname'] opentsdb Hostname of OpenTSDB server opentsdb (IN HANDLER SCRIPT)
['opentsdb_handler']['port'] Integer Port of OpenTSDB server 4242 (IN HANDLER SCRIPT)
['opentsdb_handler']['timeout'] Integer Timeout before failing to send to metric 10 (IN HANDLER SCRIPT)

Usage

opentsdb_handler::default

Include opentsdb_handler in your node's run_list and add the following attributes:

node.default['opentsdb_hander']['metrics']['flying_puppy_metric']['name'] = 'flying_puppy.metric'
node.default['opentsdb_hander']['metrics']['flying_puppy_metric']['value'] = 10
# Optional
node.default['opentsdb_hander']['metrics]['flying_puppy_metric']['tags'] = {"breed" => "corgi"}

You can add as many metrics to this hash as you want. The timestamp will be created at the start of the handler.

Contributing

  1. Fork the repository on Github
  2. bundle install
  3. Make changes
  4. Test your changes Testing

Testing

Integration tests are run with test-kitchen, kitchen-vagrant, and serverspec for integration testing. You can take a look at [.kitchen.yml] for how tests are set up. Run with:

rake kitchen:all

Unit testing is run with ChefSpec

Linting is done with foodcritic and rubocop

Run unit and linting with:

rake test

License and Authors

Authors: michael.wood@optimizely.com

About

Chef handler for sending metrics to OpentTSDB

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages