Class: Fluent::Plugin::RecordsMergerOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::RecordsMergerOutput
show all
- Defined in:
- lib/fluent/plugin/out_records_merger.rb
Overview
Defined Under Namespace
Classes: PlaceholderExpander
Constant Summary
collapse
- PATTERN_MAX_NUM =
20
Instance Method Summary
collapse
Instance Method Details
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
|
# File 'lib/fluent/plugin/out_records_merger.rb', line 50
def configure(conf)
super
@tag = conf['tag'] @last_records = {}
@main_tag = conf['main_tag']
@sub_tags = []
(1..PATTERN_MAX_NUM).each do |i|
next unless conf["sub_tag#{i}"]
@sub_tags.push(conf["sub_tag#{i}"])
end
if conf['merge_timing']
@merge_timing = conf['merge_timing']
end
@tolerable_time_range = conf['tolerable_time_range'].to_i
@flags4merge = Array.new(@sub_tags.size + 1, 0)
@force_emit = conf['force_emit']
map = {}
conf.elements.select { |element| element.name == 'record' }.each do |element|
element.each_pair do |k, v|
element.key?(k) map[k] = parse_value(v)
end
end
placeholder_expander_params = {
log: log,
auto_typecast: @auto_typecast
}
@placeholder_expander = PlaceholderExpander.new(placeholder_expander_params)
@map = @placeholder_expander.preprocess_map(map)
@tag = @placeholder_expander.preprocess_map(@tag)
@hostname = Socket.gethostname
@condition = conf['condition']
@keep_records = conf['keep_records']
end
|
#process(tag, es) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/fluent/plugin/out_records_merger.rb', line 103
def process(tag, es)
if @merge_timing == 'before'
if @main_tag == tag
store_to_lastrecords(tag, es)
@flags4merge[0] = 1
check_timegap if @tolerable_time_range > 0
emit_new_event(es) if @flags4merge.all? { |flag| flag == 1 }
elsif @sub_tags.include?(tag)
store_to_lastrecords(tag, es)
@flags4merge[@sub_tags.index(tag) + 1] = 1
check_timegap if @tolerable_time_range > 0
end
elsif @merge_timing == 'after'
if @main_tag == tag
store_to_lastrecords(tag, es)
@flags4merge[0] = 1
check_timegap if @tolerable_time_range > 0
elsif @sub_tags.include?(tag)
if @flags4merge[0] == 1
store_to_lastrecords(tag, es)
@flags4merge[@sub_tags.index(tag) + 1] = 1
check_timegap if @tolerable_time_range > 0
emit_new_event(es) if @flags4merge.all? {|flag| flag == 1}
end
else
p 'something else has come! check it!' + tag.to_s
end
elsif @merge_timing == 'simple'
if @main_tag == tag
store_to_lastrecords(tag, es)
@flags4merge[0] = 1
check_timegap if @tolerable_time_range > 0
emit_new_event(es) if @flags4merge.all? { |flag| flag == 1 }
elsif @sub_tags.include?(tag)
store_to_lastrecords(tag, es)
@flags4merge[@sub_tags.index(tag) + 1] = 1
check_timegap if @tolerable_time_range > 0
emit_new_event(es) if @flags4merge.all? { |flag| flag == 1 }
else
p 'something else has come! check it!' + tag.to_s
end
end
rescue StandardError => e
log.warn "record_reformer: #{e.class} #{e.message} #{e.backtrace.first}"
log.debug "record_reformer: tag:#{@tag} map:#{@map} record:#{@last_records} placeholder_values"
end
|
#shutdown ⇒ Object
99
100
101
|
# File 'lib/fluent/plugin/out_records_merger.rb', line 99
def shutdown
super
end
|
#start ⇒ Object
95
96
97
|
# File 'lib/fluent/plugin/out_records_merger.rb', line 95
def start
super
end
|