From 361755080701a5a7ee15771d0cb40539fa5d6066 Mon Sep 17 00:00:00 2001 From: Ahmad Hassan Date: Wed, 26 Feb 2025 11:33:46 +0500 Subject: [PATCH] [keystone-k8s] Enable request ids logging in keystone k8s. The keystone-k8s should show request ids in the keystone container logs if they exist in the request context. Closes-Bug: #2097119. Change-Id: If47b370774d14bd86a4ab15c0f4fc15276f6c0b8 --- charms/keystone-k8s/src/templates/keystone.conf.j2 | 2 ++ charms/keystone-k8s/src/templates/logging.conf.j2 | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/charms/keystone-k8s/src/templates/keystone.conf.j2 b/charms/keystone-k8s/src/templates/keystone.conf.j2 index 223f1513..876aefb2 100644 --- a/charms/keystone-k8s/src/templates/keystone.conf.j2 +++ b/charms/keystone-k8s/src/templates/keystone.conf.j2 @@ -5,6 +5,8 @@ ############################################################################### [DEFAULT] log_config_append = /etc/keystone/logging.conf +logging_context_format_string = %(asctime)s %(levelname)s %(name)s [%(global_request_id)s %(request_id)s %(user_identity)s] %(message)s +logging_default_format_string = %(asctime)s %(levelname)s %(name)s %(message)s debug = {{ options.debug }} {% if amqp -%} diff --git a/charms/keystone-k8s/src/templates/logging.conf.j2 b/charms/keystone-k8s/src/templates/logging.conf.j2 index 479e21e6..f60c1817 100644 --- a/charms/keystone-k8s/src/templates/logging.conf.j2 +++ b/charms/keystone-k8s/src/templates/logging.conf.j2 @@ -2,7 +2,7 @@ keys=root [formatters] -keys=normal,normal_with_name,debug +keys=normal,normal_with_name,debug,context [handlers] keys=production,devel @@ -22,13 +22,13 @@ level={{ ks_logging.log_level }} {% else -%} level=ERROR {% endif -%} -formatter=normal_with_name +formatter=context args=(sys.stdout,) [handler_file] class=FileHandler level=DEBUG -formatter=normal_with_name +formatter=context # args=('/var/log/keystone/keystone.log', 'a') [handler_devel] @@ -45,3 +45,6 @@ format=(%(name)s): %(asctime)s %(levelname)s %(message)s [formatter_debug] format=(%(name)s): %(asctime)s %(levelname)s %(module)s %(funcName)s %(message)s + +[formatter_context] +class=oslo_log.formatters.ContextFormatter