Class: Fluent::Plugin::NotifierOutput::State
- Inherits:
-
Object
- Object
- Fluent::Plugin::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.
477 478 479 480 481 482 483 484 485 486 487 |
# File 'lib/fluent/plugin/out_notifier.rb', line 477 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)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def counter @counter end |
#first_notified ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def first_notified @first_notified end |
#last_notified ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def last_notified @last_notified end |
#level ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def level @level end |
#pattern ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def pattern @pattern end |
#stage ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def stage @stage end |
#target_key ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def target_key @target_key end |
#target_tag ⇒ Object
level: :warn, :crit stage: 0(1st)/1(2nd)/2(3rd)
475 476 477 |
# File 'lib/fluent/plugin/out_notifier.rb', line 475 def target_tag @target_tag end |
Instance Method Details
#suppress?(definition, notification) ⇒ Boolean
489 490 491 492 493 494 495 |
# File 'lib/fluent/plugin/out_notifier.rb', line 489 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
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 |
# File 'lib/fluent/plugin/out_notifier.rb', line 497 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 |