Last active
December 4, 2015 03:12
-
-
Save priancho/204c0f3b01f0d753fb3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- encoding: utf-8 -*- | |
# | |
# | |
# log shortener for Hadoop logs | |
# | |
# History: | |
# 2015/12/04,hancheol.cho - Simple rule-based (1:1) log shortening algorithm | |
# | |
PATTS = { | |
/org\.apache\.hadoop/ => "<OAH>", | |
/[Nn]amenode/ => "<NN>", | |
/[Rr]esource[Mn]anager/ => "<RM>", | |
/[Dd]ata[Nn]ode/ => "<DN>", | |
/[Nn]ode[Mm]anager/ => "<NM>", | |
/[Cc]ontainer[Mm]anager/ => "<CM>", | |
/LinuxContainerExecutor/ => "<LCE>", | |
/[Aa]uthorization/ => "<AuthZ>", | |
/[Mm]anager/ => "<Mgr>", | |
/[Ss]uccessful/ => "<OK>", | |
/KERBEROS/ => "<KRB>" | |
} | |
$stdin.each do |line| | |
line = line.rstrip | |
dt, tm, logLvl, logMsg = line.split(" ", 4) | |
PATTS.each do |pat, val| | |
logMsg = logMsg.gsub(pat, val) | |
end | |
puts "#{dt} #{tm} #{logLvl} #{logMsg}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment