diff --git a/armada/api/__init__.py b/armada/api/__init__.py index df88295f..ab52c179 100644 --- a/armada/api/__init__.py +++ b/armada/api/__init__.py @@ -27,6 +27,8 @@ from armada.handlers.tiller import Tiller CONF = cfg.CONF +HEALTH_PATH = 'health' + class BaseResource(object): diff --git a/armada/api/middleware.py b/armada/api/middleware.py index 426f23b7..135ea156 100644 --- a/armada/api/middleware.py +++ b/armada/api/middleware.py @@ -14,6 +14,8 @@ import re +from armada.api import HEALTH_PATH + from uuid import UUID from oslo_config import cfg @@ -100,9 +102,18 @@ class LoggingMiddleware(object): # don't log any headers beginning with X-* hdr_exclude = re.compile('x-.*', re.IGNORECASE) + # don't log anything for health checks + path_exclude = re.compile('.*/{}$'.format(HEALTH_PATH)) + + def exclude_path(self, req): + return LoggingMiddleware.path_exclude.match(req.path) + def process_request(self, req, resp): """ Set up values to be logged across the request """ + if self.exclude_path(req): + return + ctx = req.context extra = { 'user': ctx.user, @@ -115,6 +126,9 @@ class LoggingMiddleware(object): def process_response(self, req, resp, resource, req_succeeded): """ Log the response information """ + if self.exclude_path(req): + return + ctx = req.context extra = { 'user': ctx.user, diff --git a/armada/api/server.py b/armada/api/server.py index a8e64907..c32b5a98 100644 --- a/armada/api/server.py +++ b/armada/api/server.py @@ -18,7 +18,7 @@ from oslo_policy import policy from oslo_log import log as logging from armada import conf -from armada.api import ArmadaRequest +from armada.api import ArmadaRequest, HEALTH_PATH from armada.api.controller.armada import Apply from armada.api.middleware import AuthMiddleware from armada.api.middleware import ContextMiddleware @@ -60,7 +60,7 @@ def create(enable_middleware=CONF.middleware): # Configure API routing url_routes_v1 = ( - ('health', Health()), + (HEALTH_PATH, Health()), ('apply', Apply()), ('releases', Release()), ('rollback/{release}', Rollback()),