Created
January 6, 2014 08:49
-
-
Save shiumachi/8279961 to your computer and use it in GitHub Desktop.
Hadoopのログから日付、ログレベル、メッセージを分割して返す
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
example = """2014-01-05 22:20:50,307 INFO org.apache.hadoop.hdfs.server.datanode.BlockPoolSliceScanner: Verification succeeded for BP-1337840909-192.168.0.1-1374311151785:blk_8462243608396789329_201176 | |
""" | |
def parse_datetime_and_level(line): | |
""" input: hadoop log | |
output: [datetime, loglevel, message] | |
""" | |
import re | |
r = re.compile("(^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}) ([A-Z]{4,5}) (.*)") | |
m = r.match(line) | |
return m.groups() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment