From 8ea12d9b33bb12132fb1d814049ee8f5a05d4ba1 Mon Sep 17 00:00:00 2001 From: Tarik Zegmott Date: Fri, 6 Sep 2024 14:10:13 -0400 Subject: [PATCH] fix: loki logs in workflow web (#117) * fix(workflow-run-loki): add logic to add pipeline and site to the loki tags workflow web wasn't able to find the logs for Work since the relevant tags were missing from the Loki logs. It also appears that the python driver may not accept logs that do not have any tags at all. * refactor(chimefrb-workspace): add loki tags config to workspace this is currently a empty object since I couldn't think of any useful static tags to add to the logs. --- workflow/cli/run.py | 23 +++++++++++++++++++++++ workflow/workspaces/chimefrb.yml | 4 ++++ 2 files changed, 27 insertions(+) diff --git a/workflow/cli/run.py b/workflow/cli/run.py index df5cea5..3ecaf53 100644 --- a/workflow/cli/run.py +++ b/workflow/cli/run.py @@ -196,6 +196,29 @@ def run( "[bold red]Backend Checks [/bold red]", extra=dict(markup=True, color="green"), ) + # Add pipeline and site to loki tags + if config.get("logging", {}).get("loki", {}).get("tags", {}): + # Loki tags exist, add pipeline and site + config["logging"]["loki"]["tags"].update( + { + # Assumes that there is only one bucket + "pipeline": buckets[0], + "site": site, + } + ) + else: + # Missing Logging config in Workspace + config.update({ + "logging": { + "loki": { + "tags": { + # Assumes that there is only one bucket + "pipeline": buckets[0], + "site": site, + } + } + } + }) loki_status: bool = configure.loki(logger=logger, config=config) logger.info(f"Loki Logs: {'✅' if loki_status else '❌'}") http: HTTPContext = HTTPContext(backends=["buckets"]) diff --git a/workflow/workspaces/chimefrb.yml b/workflow/workspaces/chimefrb.yml index 50b98a8..27e9811 100644 --- a/workflow/workspaces/chimefrb.yml +++ b/workflow/workspaces/chimefrb.yml @@ -104,3 +104,7 @@ deployers: chime: docker: client_url: tcp://frb-vsop.chime:2375 + +logging: + loki: + tags: {}