From a4ba055e103b3086ce62dac20c23ac7e3d0ec636 Mon Sep 17 00:00:00 2001 From: Christopher Bartz Date: Tue, 28 May 2024 23:01:49 +0200 Subject: [PATCH] Add juju_charm label to logs (#111) * add juju_charm label to logs * lint * add job labels * use python38 dict merge --- src/charm.py | 3 ++- src/grafana_agent.py | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/charm.py b/src/charm.py index 31972d8..5d149ab 100755 --- a/src/charm.py +++ b/src/charm.py @@ -416,6 +416,7 @@ def _additional_log_configs(self) -> List[Dict[str, Any]]: "targets": ["localhost"], "labels": { "__path__": "/var/log/**/*log", + "job": "varlog", **self._own_labels, }, } @@ -423,7 +424,7 @@ def _additional_log_configs(self) -> List[Dict[str, Any]]: }, { "job_name": "syslog", - "journal": {"labels": self._own_labels}, + "journal": {"labels": {**self._own_labels, **{"job": "syslog"}}}, "pipeline_stages": [ { "drop": { diff --git a/src/grafana_agent.py b/src/grafana_agent.py index 2f5444f..5c7faf5 100644 --- a/src/grafana_agent.py +++ b/src/grafana_agent.py @@ -771,6 +771,7 @@ def _instance_topology(self) -> Dict[str, str]: "juju_model_uuid": self.model.uuid, "juju_application": self.model.app.name, "juju_unit": self.model.unit.name, + "juju_charm": self.meta.name, } @property