Skip to content

Commit

Permalink
Fix compatibility with newer versions of Graphite (#64)
Browse files Browse the repository at this point in the history
* Fix compatibility with newer versions of Graphite

Tags require brackets with newer versions of graphite.
  • Loading branch information
jwatroba authored and majormoses committed Mar 1, 2018
1 parent 8d78caf commit 2f5d928
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)

## [Unreleased]
### Added
- Added -t flag to handler-graphite-event.rb to support post 1.0 versions of graphite which require tags sent as arrays.

## [3.0.0] - 2017-12-04
### Breaking Change
Expand Down
10 changes: 9 additions & 1 deletion bin/handler-graphite-event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
require 'json'

class GraphiteEvent < Sensu::Handler
option :tags_as_array,
description: 'send tags as array - for post graphite 1.0 compatibility.',
short: '-t',
long: '--tags-as-array',
boolean: true,
required: false,
default: false

def post_event(uri, body)
uri = URI.parse(uri)
req = Net::HTTP::Post.new(uri.path)
Expand Down Expand Up @@ -60,7 +68,7 @@ def handle

body = {
'what' => 'sensu_event',
'tags' => tags.join(','),
'tags' => config[:tags_as_array] ? [tags.join(',')] : tags.join(','),
'data' => event_status,
'when' => Time.now.to_i
}
Expand Down

0 comments on commit 2f5d928

Please sign in to comment.