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
|
# File 'lib/logstash/filters/pilar.rb', line 62
def filter(event)
unless Thread.current[:gramdict] && Thread.current[:preprocessor]
Thread.current[:gramdict] = GramDict.new(@maximum_gram_dict_size)
Thread.current[:preprocessor] =
Preprocessor.new(Thread.current[:gramdict], @logformat, @content_specifier, @regexes)
if @seed_logs_path && ::File.exist?(@seed_logs_path)
::File.open(@seed_logs_path, 'r') do |seed_logs|
seed_logs.each_line do |seed_log|
Thread.current[:preprocessor].process_log_event(seed_log, @dynamic_token_threshold, false)
end
end
end
end
if event.get(@source_field)
processed_log = Thread.current[:preprocessor].process_log_event(
event.get(@source_field), @dynamic_token_threshold, true
)
if processed_log
template_string, dynamic_tokens = processed_log
event.set('template_string', template_string)
event.set('dynamic_tokens', dynamic_tokens)
else
event.set('dynamic_tokens', nil)
event.set('template_string', nil)
end
raw_log = event.get(@source_field)
event.set('raw_log', raw_log.strip)
end
filter_matched(event)
end
|