From 70f5e73320a8f214517f252e485ea1183c099987 Mon Sep 17 00:00:00 2001 From: Manuel Amador Date: Thu, 10 Oct 2024 14:24:03 +0200 Subject: [PATCH] Hide Prometheus query unless explicitly disclosed. --- plugins/sensors/ic_os_rollout.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/sensors/ic_os_rollout.py b/plugins/sensors/ic_os_rollout.py index f83d1bd..2347f8b 100644 --- a/plugins/sensors/ic_os_rollout.py +++ b/plugins/sensors/ic_os_rollout.py @@ -292,7 +292,9 @@ def execute(self, context: Context, event: Any = None) -> None: + f'ic_subnet="{subnet_id}"' + "}) by (ic_active_version, ic_subnet)" ) - self.log.info(f"Querying Prometheus servers: {query}") + print("::group::Querying Prometheus servers") + self.log.info(f"{query}") + print("::endgroup::") res = prom.query_prometheus_servers(self.network.prometheus_urls, query) if len(res) == 1 and res[0]["metric"]["ic_active_version"] == git_revision: current_replica_count = int(res[0]["value"]) @@ -406,7 +408,9 @@ def send_notification_if_necessary(subnet_id: str) -> None: "subnet_id": subnet_id, } ) - self.log.info(f"Querying Prometheus servers: {query}") + print("::group::Querying Prometheus servers") + self.log.info(f"{query}") + print("::endgroup::") res = prom.query_prometheus_servers(self.network.prometheus_urls, query) if len(res) > 0: self.log.info("There are still Prometheus alerts on the subnet:") @@ -631,7 +635,9 @@ def execute(self, context: Context, event: Any = None) -> None: f" last 1 day before {subnet_id}" ) query = "sum(changes(ic_replica_info{" + f'ic_subnet="{other}"' + "}[1d]))" - self.log.info(f"Querying Prometheus servers: {query}") + print("::group::Querying Prometheus servers") + self.log.info(f"{query}") + print("::endgroup::") res = prom.query_prometheus_servers(self.network.prometheus_urls, query) if not res: raise RuntimeError(("Prometheus returned no sum of updates: %r" % res,))