Skip to content

Commit 2f5d928

Browse files
jwatrobamajormoses
authored andcommitted
Fix compatibility with newer versions of Graphite (#64)
* Fix compatibility with newer versions of Graphite Tags require brackets with newer versions of graphite.
1 parent 8d78caf commit 2f5d928

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
55

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

810
## [3.0.0] - 2017-12-04
911
### Breaking Change

bin/handler-graphite-event.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
require 'json'
2323

2424
class GraphiteEvent < Sensu::Handler
25+
option :tags_as_array,
26+
description: 'send tags as array - for post graphite 1.0 compatibility.',
27+
short: '-t',
28+
long: '--tags-as-array',
29+
boolean: true,
30+
required: false,
31+
default: false
32+
2533
def post_event(uri, body)
2634
uri = URI.parse(uri)
2735
req = Net::HTTP::Post.new(uri.path)
@@ -60,7 +68,7 @@ def handle
6068

6169
body = {
6270
'what' => 'sensu_event',
63-
'tags' => tags.join(','),
71+
'tags' => config[:tags_as_array] ? [tags.join(',')] : tags.join(','),
6472
'data' => event_status,
6573
'when' => Time.now.to_i
6674
}

0 commit comments

Comments
 (0)