Class: Fluent::NotifierOutput::Definition
- Inherits:
-
Object
- Object
- Fluent::NotifierOutput::Definition
- Defined in:
- lib/fluent/plugin/out_notifier.rb
Instance Attribute Summary collapse
-
#check(tag, time, record, key) ⇒ Object
{ ‘pattern’ => ‘http_status_errors’, ‘target_tag’ => ‘httpstatus.blog’, ‘target_key’ => ‘blog_5xx_percentage’, ‘check_type’ => ‘numeric_upward’ ‘level’ => ‘warn’, # ‘regexp’ => ‘[WARN] .* MUST BE CHECKED!$’ ‘threshold’ => 25, ‘value’ => 49, # ‘value’ => ‘2012/05/15 18:01:59 [WARN] wooooops, MUST BE CHECKED!’ ‘message_time’ => Time.instance }.
-
#crit_regexp ⇒ Object
for ‘string_find’.
-
#crit_threshold ⇒ Object
for ‘numeric_upward’, ‘numeric_downward’.
-
#exclude_key_pattern ⇒ Object
Returns the value of attribute exclude_key_pattern.
-
#intervals ⇒ Object
Returns the value of attribute intervals.
-
#pattern ⇒ Object
Returns the value of attribute pattern.
-
#repetitions ⇒ Object
Returns the value of attribute repetitions.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#tag_crit ⇒ Object
Returns the value of attribute tag_crit.
-
#tag_warn ⇒ Object
Returns the value of attribute tag_warn.
-
#target_key_pattern ⇒ Object
Returns the value of attribute target_key_pattern.
-
#target_keys ⇒ Object
Returns the value of attribute target_keys.
-
#warn_regexp ⇒ Object
for ‘string_find’.
-
#warn_threshold ⇒ Object
for ‘numeric_upward’, ‘numeric_downward’.
Instance Method Summary collapse
-
#initialize(element, defaults) ⇒ Definition
constructor
A new instance of Definition.
- #match?(key) ⇒ Boolean
Constructor Details
#initialize(element, defaults) ⇒ Definition
Returns a new instance of Definition.
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/fluent/plugin/out_notifier.rb', line 282 def initialize(element, defaults) element.keys.each do |k| case k when 'pattern' @pattern = element[k] when 'check' case element[k] when 'numeric_upward' @check = :upward unless element.has_key?('crit_threshold') and element.has_key?('warn_threshold') raise Fluent::ConfigError, "Both of crit_threshold and warn_threshold must be specified for 'check numeric_upward'" end @crit_threshold = element['crit_threshold'].to_f @warn_threshold = element['warn_threshold'].to_f when 'numeric_downward' @check = :downward unless element.has_key?('crit_threshold') and element.has_key?('warn_threshold') raise Fluent::ConfigError, "Both of crit_threshold and warn_threshold must be specified for 'check_numeric_downward'" end @crit_threshold = element['crit_threshold'].to_f @warn_threshold = element['warn_threshold'].to_f when 'string_find' @check = :find unless element.has_key?('crit_regexp') and element.has_key?('warn_regexp') raise Fluent::ConfigError, "Both of crit_regexp and warn_regexp must be specified for 'check string_find'" end @crit_regexp = Regexp.compile(element['crit_regexp'].to_s) @warn_regexp = Regexp.compile(element['warn_regexp'].to_s) else raise Fluent::ConfigError, "invalid check type: #{element[k]}" end when 'target_keys' @target_keys = element['target_keys'].split(',') when 'target_key_pattern' @target_key_pattern = Regexp.compile(element['target_key_pattern']) @exclude_key_pattern = Regexp.compile(element['exclude_key_pattern'] || '^$') end end if @pattern.nil? or @pattern.length < 1 raise Fluent::ConfigError, "pattern must be set" end if @target_keys.nil? and @target_key_pattern.nil? raise Fluent::ConfigError, "out_notifier needs one of target_keys or target_key_pattern" end @tag = element['tag'] || defaults[:tag] @tag_warn = element['tag_warn'] || defaults[:tag_warn] @tag_crit = element['tag_crit'] || defaults[:tag_crit] @intervals = [ (element['interval_1st'] || defaults[:interval_1st]), (element['interval_2nd'] || defaults[:interval_2nd]), (element['interval_3rd'] || defaults[:interval_3rd]) ] @repetitions = [ (element['repetitions_1st'] || defaults[:repetitions_1st]), (element['repetitions_2nd'] || defaults[:repetitions_2nd]) ] end |
Instance Attribute Details
#check(tag, time, record, key) ⇒ Object
'pattern' => 'http_status_errors',
'target_tag' => 'httpstatus.blog',
'target_key' => 'blog_5xx_percentage',
'check_type' => 'numeric_upward'
'level' => 'warn', # 'regexp' => '[WARN] .* MUST BE CHECKED!$'
'threshold' => 25,
'value' => 49, # 'value' => '2012/05/15 18:01:59 [WARN] wooooops, MUST BE CHECKED!'
'message_time' => Time.instance
358 359 360 |
# File 'lib/fluent/plugin/out_notifier.rb', line 358 def check @check end |
#crit_regexp ⇒ Object
for ‘string_find’
280 281 282 |
# File 'lib/fluent/plugin/out_notifier.rb', line 280 def crit_regexp @crit_regexp end |
#crit_threshold ⇒ Object
for ‘numeric_upward’, ‘numeric_downward’
279 280 281 |
# File 'lib/fluent/plugin/out_notifier.rb', line 279 def crit_threshold @crit_threshold end |
#exclude_key_pattern ⇒ Object
Returns the value of attribute exclude_key_pattern.
278 279 280 |
# File 'lib/fluent/plugin/out_notifier.rb', line 278 def exclude_key_pattern @exclude_key_pattern end |
#intervals ⇒ Object
Returns the value of attribute intervals.
277 278 279 |
# File 'lib/fluent/plugin/out_notifier.rb', line 277 def intervals @intervals end |
#pattern ⇒ Object
Returns the value of attribute pattern.
278 279 280 |
# File 'lib/fluent/plugin/out_notifier.rb', line 278 def pattern @pattern end |
#repetitions ⇒ Object
Returns the value of attribute repetitions.
277 278 279 |
# File 'lib/fluent/plugin/out_notifier.rb', line 277 def repetitions @repetitions end |
#tag ⇒ Object
Returns the value of attribute tag.
276 277 278 |
# File 'lib/fluent/plugin/out_notifier.rb', line 276 def tag @tag end |
#tag_crit ⇒ Object
Returns the value of attribute tag_crit.
276 277 278 |
# File 'lib/fluent/plugin/out_notifier.rb', line 276 def tag_crit @tag_crit end |
#tag_warn ⇒ Object
Returns the value of attribute tag_warn.
276 277 278 |
# File 'lib/fluent/plugin/out_notifier.rb', line 276 def tag_warn @tag_warn end |
#target_key_pattern ⇒ Object
Returns the value of attribute target_key_pattern.
278 279 280 |
# File 'lib/fluent/plugin/out_notifier.rb', line 278 def target_key_pattern @target_key_pattern end |
#target_keys ⇒ Object
Returns the value of attribute target_keys.
278 279 280 |
# File 'lib/fluent/plugin/out_notifier.rb', line 278 def target_keys @target_keys end |
#warn_regexp ⇒ Object
for ‘string_find’
280 281 282 |
# File 'lib/fluent/plugin/out_notifier.rb', line 280 def warn_regexp @warn_regexp end |
#warn_threshold ⇒ Object
for ‘numeric_upward’, ‘numeric_downward’
279 280 281 |
# File 'lib/fluent/plugin/out_notifier.rb', line 279 def warn_threshold @warn_threshold end |
Instance Method Details
#match?(key) ⇒ Boolean
340 341 342 343 344 345 346 |
# File 'lib/fluent/plugin/out_notifier.rb', line 340 def match?(key) if @target_keys @target_keys.include?(key) elsif @target_key_pattern @target_key_pattern.match(key) and not @exclude_key_pattern.match(key) end end |