Class: Fluent::NotifierOutput::State
- Inherits:
-
Object
- Object
- Fluent::NotifierOutput::State
- Defined in:
- lib/fluent/plugin/out_notifier.rb
Instance Attribute Summary collapse
-
#counter ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#first_notified ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#last_notified ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#level ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#pattern ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#stage ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#target_key ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
-
#target_tag ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd).
Instance Method Summary collapse
-
#initialize(notification) ⇒ State
constructor
A new instance of State.
- #suppress?(definition, notification) ⇒ Boolean
- #update_notified(definition, notification) ⇒ Object
Constructor Details
#initialize(notification) ⇒ State
Returns a new instance of State.
448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/fluent/plugin/out_notifier.rb', line 448 def initialize(notification) @pattern = notification[:pattern] @target_tag = notification[:target_tag] @target_key = notification[:target_key] @level = notification['level'] @stage = 0 @counter = 1 t = Fluent::Engine.now @first_notified = t @last_notified = t end |
Instance Attribute Details
#counter ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def counter @counter end |
#first_notified ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def first_notified @first_notified end |
#last_notified ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def last_notified @last_notified end |
#level ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def level @level end |
#pattern ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def pattern @pattern end |
#stage ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def stage @stage end |
#target_key ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def target_key @target_key end |
#target_tag ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
446 447 448 |
# File 'lib/fluent/plugin/out_notifier.rb', line 446 def target_tag @target_tag end |
Instance Method Details
#suppress?(definition, notification) ⇒ Boolean
460 461 462 463 464 465 466 |
# File 'lib/fluent/plugin/out_notifier.rb', line 460 def suppress?(definition, notification) if @level == notification['level'] (Fluent::Engine.now - @last_notified) <= definition.intervals[@stage] else true end end |
#update_notified(definition, notification) ⇒ Object
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/fluent/plugin/out_notifier.rb', line 468 def update_notified(definition, notification) t = Fluent::Engine.now if @level == notification['level'] rep = definition.repetitions[@stage] if rep and rep > 0 @counter += 1 if @counter > rep @stage += 1 @counter = 0 end end else @level = notification['level'] @stage = 0 @counter = 1 @first_notified = t end @last_notified = t end |