16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/logstash/filters/sidekiq.rb', line 16
def filter(event)
sidekiq_logged = /\A(?<time>[\d\-]+T[\d:]+Z) (?<pid>\d+) TID-(?<tid>\w+)(?<context>.*?) (?<severity>(?i:DEBUG|INFO|WARN|ERROR|FATAL|UNKNOWN|ANY)): /
if sidekiq_match = event[@source].match(sidekiq_logged)
event['sidekiq'] ||= {}
event['sidekiq'].update(sidekiq_match.names.map { |name| {name => sidekiq_match[name]} }.inject({}, &:update))
event['@timestamp'] = Time.parse(sidekiq_match['time']).utc
job_context = /\A\s*(?<job_name>.+) JID-(?<jid>\w+)\z/
if context_match = sidekiq_match['context'].match(job_context)
event['sidekiq']['context'] = context_match.names.map { |name| {name => context_match[name]} }.inject({}, &:update)
end
event[@source] = sidekiq_match.post_match if @consume
end
end
|