Created
October 27, 2017 01:12
-
-
Save anacrolix/a705287b7de2d2a0176b53ae07943719 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import time, datetime, re | |
def parse_go(logger, line): | |
event = { | |
'msg_text': line, | |
'priority': 'low', | |
} | |
try: | |
date = datetime.datetime.strptime(line[:19], "%Y/%m/%d %H:%M:%S") | |
except ValueError: | |
pass | |
else: | |
date = time.mktime(date.timetuple()) | |
event['timestamp'] = date | |
if re.search(r'\bpanic\b', line): | |
event['alert_type'] = 'warning' | |
if line.startswith("panic:"): | |
event['priority'] = 'normal' | |
event['alert_type'] = 'error' | |
return event | |
def main(): | |
import sys | |
for line in sys.stdin: | |
print(globals()[sys.argv[1]](None, line)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment