Description:
SlowQueryLog from mysql.utilities.common.parser fails to parse MySQL 5.7 slowquery log:
Traceback (most recent call last):
File "./test.py", line 16, in <module>
for entry in log:
File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 251, in next
entry = self._parse_entry()
File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 716, in _parse_entry
self._parse_timestamp(line, entry)
File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 609, in _parse_timestamp
info = self._parse_line(_SLOW_TIMESTAMP_CRE, line)
File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 570, in _parse_line
line[:30])
mysql.utilities.exception.LogParserError: ('Failed parsing Slow Query line: # Time: 2017-03-14T16:00:40.16', 0)
How to repeat:
Try to parse MySQL 5.7 slow query log with this basic script:
#!/usr/bin/env python
from mysql.utilities.common.parser import SlowQueryLog
if __name__ == '__main__':
slow_file = "/pathToLogFile/slowquery.log"
slow_log = open(slow_file)
log = SlowQueryLog(slow_log)
for entry in log:
for k, v in entry.iteritems():
print k, v
No issue with MySQL 5.6 slow query log. Time field in slow query log has changed between 5.6 and 5.7:
5.6:
# Time: 170312 3:33:02
5.7:
# Time: 2017-03-14T16:00:40.165473+01:00