Class: Fluent::SensuOutput
- Inherits:
-
BufferedOutput
- Object
- BufferedOutput
- Fluent::SensuOutput
- Defined in:
- lib/fluent/plugin/out_sensu.rb
Overview
Fluentd output plugin to send checks to sensu-client.
Constant Summary collapse
- CHECK_NAME_PATTERN =
Pattern for check names.
/\A[\w.-]+\z/- OK_PATTERN =
Pattern for OK status.
/\A(0|OK)\z/i- WARNING_PATTERN =
Pattern for WARNING status.
/\A(1|WARNING|warn)\z/i- CRITICAL_PATTERN =
Pattern for CRITICAL status.
/\A(2|CRITICAL|crit)\z/i- UNKNOWN_PATTERN =
Pattern for UNKNOWN status.
/\A(3|UNKNOWN|CUSTOM)\z/i
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
- #to_json(data) ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#configure(conf) ⇒ Object
103 104 105 106 107 |
# File 'lib/fluent/plugin/out_sensu.rb', line 103 def configure(conf) super reject_invalid_check_name reject_invalid_flapping_thresholds end |
#format(tag, time, record) ⇒ Object
146 147 148 |
# File 'lib/fluent/plugin/out_sensu.rb', line 146 def format(tag, time, record) [tag, time, record].to_msgpack end |
#to_json(data) ⇒ Object
200 201 202 203 204 205 206 207 208 |
# File 'lib/fluent/plugin/out_sensu.rb', line 200 def to_json(data) raw_json = data.to_json.force_encoding(Encoding::BINARY) regex = /[\xc0-\xdf][\x80-\xbf] |[\xe0-\xef][\x80-\xbf]{2} |[\xf0-\xf7][\x80-\xbf]{3}/nx return raw_json.gsub(regex) { |ch| ch.unpack('U*').pack('n*').unpack('H*')[0].gsub(/.+/, %q(\\\\u\&)) } end |
#write(chunk) ⇒ Object
152 153 154 155 156 157 |
# File 'lib/fluent/plugin/out_sensu.rb', line 152 def write(chunk) chunk.msgpack_each { |(tag, time, record)| payload = make_check_result(tag, time, record) send_check(@server, @port, payload) } end |