This cookbook sets up a handler that reports to OpenTSDB at the end of a chef run
The only requirement is the chef_handler cookbook
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) |
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.
- Fork the repository on Github
bundle install
- Make changes
- Test your changes 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
Authors: michael.wood@optimizely.com