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
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/fluent/plugin/out_field_multiregex.rb', line 61
def parse_field(record)
if (parse_key.nil?) || !(record.key?(parse_key))
return record
end
source = record[parse_key].to_s
source_arr = []
if !(multiline == false)
source_arr = source.split( /\r?\n/ )
else
source_arr << source
end
input_patterns = [pattern1,pattern2,pattern3,pattern4,
pattern5,pattern6,pattern7,pattern8,
pattern9,pattern10,pattern11,pattern12,
pattern13,pattern14,pattern15,pattern16,
pattern17,pattern18,pattern19,pattern20
]
matched = false
input_patterns.each do |input_pattern|
if !(input_pattern.nil?)
source_arr.each do |source_elem|
matched = false
matched_hash = source_elem.match(input_pattern)
if !(matched_hash.nil?)
matched_hash.names.each do |key|
val = matched_hash[key]
if val.is_i?
record[key] = val.to_i
elsif val.nan?
record[key] = val
else
record[key] = val.to_f
end
end
matched = true
end
end
end
if matched
break
end
end
return record
end
|