log-gearman-worker: remove obsolete GET debug filter, add local filter
Now that logs have moved into swift, the os-loganalyze middleware that
stripped DEBUG level logs when the URL was given a ?level= parameter
no longer functions.
We move to filtering DEBUG statements directly. Because services in
devstack now run as systemd services, their log files are actually
journalctl dumps. Thus we add a new filter for systemd style
timestamps and messages (this is loosely based on the zuul log viewer
at [1]).
[1] 8c1f4e9d6b/web/src/actions/logfile.js
Change-Id: I54087c95c809612758139136d5b3e86b1a6372be
This commit is contained in:
parent
5b30a3a6c0
commit
3119c0cddd
|
@ -135,7 +135,7 @@ class CRM114FilterFactory(object):
|
||||||
return CRM114Filter(self.script, path, fields['build_status'])
|
return CRM114Filter(self.script, path, fields['build_status'])
|
||||||
|
|
||||||
|
|
||||||
class SeverityFilter(object):
|
class OsloSeverityFilter(object):
|
||||||
DATEFMT = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
DATEFMT = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||||
SEVERITYFMT = '(DEBUG|INFO|WARNING|ERROR|TRACE|AUDIT|CRITICAL)'
|
SEVERITYFMT = '(DEBUG|INFO|WARNING|ERROR|TRACE|AUDIT|CRITICAL)'
|
||||||
OSLO_LOGMATCH = ('^(?P<date>%s)(?P<line>(?P<pid> \d+)? '
|
OSLO_LOGMATCH = ('^(?P<date>%s)(?P<line>(?P<pid> \d+)? '
|
||||||
|
@ -157,11 +157,44 @@ class SeverityFilter(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SeverityFilterFactory(object):
|
class OsloSeverityFilterFactory(object):
|
||||||
name = "Severity"
|
name = "OsloSeverity"
|
||||||
|
|
||||||
def create(self, fields):
|
def create(self, fields):
|
||||||
return SeverityFilter()
|
return OsloSeverityFilter()
|
||||||
|
|
||||||
|
|
||||||
|
class SystemdSeverityFilter(object):
|
||||||
|
'''
|
||||||
|
Match systemd DEBUG level logs
|
||||||
|
|
||||||
|
A line to match looks like:
|
||||||
|
|
||||||
|
Aug 15 18:58:49.910786 hostname devstack@keystone.service[31400]: DEBUG uwsgi ...
|
||||||
|
'''
|
||||||
|
SYSTEMDDATE = '\w+\s+\d+\s+\d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||||
|
DATEFMT = '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}((\.|\,)\d{3,6})?'
|
||||||
|
SEVERITYFMT = '(DEBUG|INFO|WARNING|ERROR|TRACE|AUDIT|CRITICAL)'
|
||||||
|
SYSTEMD_LOGMATCH = '^(?P<date>%s)( (\S+) \S+\[\d+\]\: ' \
|
||||||
|
'(?P<severity>%s)?.*)' % (SYSTEMDDATE, SEVERITYFMT)
|
||||||
|
SYSTEMDRE = re.compile(SYSTEMD_LOGMATCH)
|
||||||
|
|
||||||
|
def process(self, msg):
|
||||||
|
m = self.SYSTEMDRE.match(msg)
|
||||||
|
if m:
|
||||||
|
if m.group('severity') == 'DEBUG':
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SystemdSeverityFilterFactory(object):
|
||||||
|
name = "SystemdSeverity"
|
||||||
|
|
||||||
|
def create(self, fields):
|
||||||
|
return SystemdSeverityFilter()
|
||||||
|
|
||||||
|
|
||||||
class LogRetriever(threading.Thread):
|
class LogRetriever(threading.Thread):
|
||||||
|
@ -290,20 +323,15 @@ class LogRetriever(threading.Thread):
|
||||||
def _get_log_data(self, source_url, retry):
|
def _get_log_data(self, source_url, retry):
|
||||||
encoding = 'raw'
|
encoding = 'raw'
|
||||||
try:
|
try:
|
||||||
# TODO(clarkb): We really should be using requests instead
|
logging.debug("Retrieving: " + source_url + ".gz")
|
||||||
# of urllib2. urllib2 will automatically perform a POST
|
req = urllib2.Request(source_url + ".gz")
|
||||||
# instead of a GET if we provide urlencoded data to urlopen
|
|
||||||
# but we need to do a GET. The parameters are currently
|
|
||||||
# hardcoded so this should be ok for now.
|
|
||||||
logging.debug("Retrieving: " + source_url + ".gz?level=INFO")
|
|
||||||
req = urllib2.Request(source_url + ".gz?level=INFO")
|
|
||||||
req.add_header('Accept-encoding', 'deflate, gzip')
|
req.add_header('Accept-encoding', 'deflate, gzip')
|
||||||
r = urllib2.urlopen(req)
|
r = urllib2.urlopen(req)
|
||||||
except urllib2.URLError:
|
except urllib2.URLError:
|
||||||
try:
|
try:
|
||||||
# Fallback on GETting unzipped data.
|
# Fallback on GETting unzipped data.
|
||||||
logging.debug("Retrieving: " + source_url + "?level=INFO")
|
logging.debug("Retrieving: " + source_url)
|
||||||
r = urllib2.urlopen(source_url + "?level=INFO")
|
r = urllib2.urlopen(source_url)
|
||||||
except:
|
except:
|
||||||
logging.exception("Unable to retrieve source file.")
|
logging.exception("Unable to retrieve source file.")
|
||||||
raise
|
raise
|
||||||
|
@ -430,7 +458,8 @@ class Server(object):
|
||||||
self.filter_factories = []
|
self.filter_factories = []
|
||||||
# Run the severity filter first so it can filter out chatty
|
# Run the severity filter first so it can filter out chatty
|
||||||
# logs.
|
# logs.
|
||||||
self.filter_factories.append(SeverityFilterFactory())
|
self.filter_factories.append(OsloSeverityFilterFactory())
|
||||||
|
self.filter_factories.append(SystemdSeverityFilterFactory())
|
||||||
crmscript = self.config.get('crm114-script')
|
crmscript = self.config.get('crm114-script')
|
||||||
crmdata = self.config.get('crm114-data')
|
crmdata = self.config.get('crm114-data')
|
||||||
if crmscript and crmdata:
|
if crmscript and crmdata:
|
||||||
|
|
Loading…
Reference in New Issue