Skip to content

Commit

Permalink
Merge pull request #2201 from DSD-DBS/session-id-in-logs
Browse files Browse the repository at this point in the history
feat: Add session_id as label to session logs
  • Loading branch information
MoritzWeber0 authored Feb 13, 2025
2 parents ee35ef4 + 88cbf23 commit 9bc9e64
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions backend/capellacollab/sessions/hooks/log_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ def post_session_creation_hook(
request.operator._create_configmap(
name=request.db_session.id,
data=self._promtail_configuration(
session_id=request.session_id,
username=request.user.name,
session_type=request.db_session.type.value,
tool=request.db_session.tool,
version_name=request.db_session.version.name,
version=request.db_session.version,
connection_method=request.connection_method,
),
)

Expand Down Expand Up @@ -102,10 +104,12 @@ def _log_collection_enabled(
@classmethod
def _promtail_configuration(
cls,
session_id: str,
username: str,
session_type: str,
tool: tools_models.DatabaseTool,
version_name: str,
version: tools_models.DatabaseVersion,
connection_method: tools_models.ToolSessionConnectionMethod,
) -> dict:
cfg = config.k8s.promtail

Expand Down Expand Up @@ -143,8 +147,10 @@ def _promtail_configuration(
"labels": {
"username": username,
"session_type": session_type,
"tool": tool.name,
"version": version_name,
"session_id": session_id,
"tool_id": tool.id,
"version_id": version.id,
"connection_method_id": connection_method.id,
"__path__": tool.config.monitoring.logging.path,
},
}
Expand Down

0 comments on commit 9bc9e64

Please sign in to comment.