Avoid including bad service names in perf.json

Some of the API services are not properly mounted under /$service/
in the apache proxy. This patch tries to avoid recording data
for "services" like "v2.0" (in the case of neutron) by only adding
names if they're all letters. A single warning is emitted for any
services excluded by this check.

For the moment this will mean we don't collect data for those services,
but when their devstack API config is fixed, they'll start to show
up.

Change-Id: I41cc300e89a4f97a008a8ba97c91f0980f9b9c3f
This commit is contained in:
Dan Smith 2022-06-23 09:25:22 -07:00
parent eacaa99853
commit fe7cfa6b8c

View File

@ -111,6 +111,7 @@ def get_http_stats_for_log(logfile):
apache_fields = ('host', 'a', 'b', 'date', 'tz', 'request', 'status', apache_fields = ('host', 'a', 'b', 'date', 'tz', 'request', 'status',
'length', 'c', 'agent') 'length', 'c', 'agent')
ignore_agents = ('curl', 'uwsgi', 'nova-status') ignore_agents = ('curl', 'uwsgi', 'nova-status')
ignored_services = set()
for line in csv.reader(open(logfile), delimiter=' '): for line in csv.reader(open(logfile), delimiter=' '):
fields = dict(zip(apache_fields, line)) fields = dict(zip(apache_fields, line))
if len(fields) != len(apache_fields): if len(fields) != len(apache_fields):
@ -146,6 +147,10 @@ def get_http_stats_for_log(logfile):
service = url.strip('/') service = url.strip('/')
rest = '' rest = ''
if not service.isalpha():
ignored_services.add(service)
continue
method_key = '%s-%s' % (agent, method) method_key = '%s-%s' % (agent, method)
try: try:
length = int(fields['length']) length = int(fields['length'])
@ -159,6 +164,10 @@ def get_http_stats_for_log(logfile):
stats[service]['largest'] = max(stats[service]['largest'], stats[service]['largest'] = max(stats[service]['largest'],
length) length)
if ignored_services:
LOG.warning('Ignored services: %s' % ','.join(
sorted(ignored_services)))
# Flatten this for ES # Flatten this for ES
return [{'service': service, 'log': os.path.basename(logfile), return [{'service': service, 'log': os.path.basename(logfile),
**vals} **vals}