I am running Python 3.8.6 on Windows-10 machine.
I have been running a python script to parse log files with no issues until now, recently I migrated to rsyslog server running on Ubuntu.
The script fails on:
fields_data = re_data.match(line)
with error"
'NoneType' object has no attribute 'group'
Log string stored in variable 'line':
2020-12-18 13:34:37 - ive - [173.168.115.108] username(CCC Digital Certs)[All_Users] - Agent login succeeded for username/CCC Digital Certs from 173.168.115.108 with Pulse-Secure/9.0.3.1667 (Windows 10) Pulse/9.0.3.1667.#015
RegEx expression:
re_data = re.compile(r'(\d{4}.\d{2}.\d{2})\s(\d+.\d+.\d+)\s.+\[(\d+\.\d+\.\d+\.\d+)\]\s(\w+)')
I've tested the regex expression on line with the string shown below and it gives me the correct answer of 4 groups Date, Time, IP, Name.
Code:
fields_data = re_data.match(line)
out_file.write(f'{fields_data.group(1)},{fields_data.group(2)},{fields_data.group(3)},{fields_data.group(4)},login\n')