Skip to content

Commit

Permalink
Hide Prometheus query unless explicitly disclosed.
Browse files Browse the repository at this point in the history
  • Loading branch information
DFINITYManu committed Oct 10, 2024
1 parent 9e1607f commit 70f5e73
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugins/sensors/ic_os_rollout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down Expand Up @@ -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:")
Expand Down Expand Up @@ -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,))
Expand Down

0 comments on commit 70f5e73

Please sign in to comment.