Class: Fluent::Plugin::ScenarioManagerOutput

Inherits:
Output
  • Object
show all
Defined in:
lib/fluent/plugin/out_scenario_manager.rb

Overview

fluentd output plugin

Constant Summary collapse

DEFAULT_STORAGE_TYPE =
'local'
PATTERN_MAX_NUM =
40
@@executing_scenario =
''

Instance Method Summary collapse

Instance Method Details

#configure(conf) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/fluent/plugin/out_scenario_manager.rb', line 64

def configure(conf)
  super
  # シナリオパラメーターを取得
  @scenarios = []
  conf.elements.select { |element| element.name.match(/^scenario\d\d?$/) }
      .each do |param|
    scenario = {}
    param.each_pair do |key, value|
      scenario.merge!(key => convert_value(value))
    end
    @scenarios.push(scenario)
  end

  # えらーならraiseする
  valid_conf?(conf)

  return unless @scenario_manage_mode

  # シナリオルールの取得
  @rules = []
  @executes = []
  rule, execute = separate_rule_and_exec(conf['if'])
  @rules.push(rule)
  @executes.push(execute)
  (1..PATTERN_MAX_NUM).each do |i|
    next unless conf["elsif#{i}"]

    rule, execute = separate_rule_and_exec(conf["elsif#{i}"])
    @rules.push(rule)
    @executes.push(execute)
  end
end

#process(tag, es) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/fluent/plugin/out_scenario_manager.rb', line 101

def process(tag, es)
  es.each do |time, record|
    # output events to ...
    unless @scenario_manage_mode
      @@executing_scenario = record['label']
      # TODO: actionタグを自由に命名できるようにする
      router.emit("serialized_action", time, record)
      break
    end

    # scenario check
    execute_idx = scenario_detector(record)

    next if execute_idx.nil?

    # execute scenario
    # マッチしたシナリオを実行する(emitする)
    router.emit(@tag || 'detected_scenario', time, generate_record_for_emit(get_scenario(@executes[execute_idx]), record))
  end
end

#startObject



97
98
99
# File 'lib/fluent/plugin/out_scenario_manager.rb', line 97

def start
  super
end