From a16337c4259d82dfd8e9ed8b8763407b7bfea939 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 11 Sep 2023 13:24:35 +0200 Subject: [PATCH] put prometheus behind a node-monitoring flag --- src/node_watch.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/node_watch.py b/src/node_watch.py index 52086d4d..2e7cbf4b 100644 --- a/src/node_watch.py +++ b/src/node_watch.py @@ -166,8 +166,8 @@ def perform_action(self): class PrometheusAction(TestnetMonitorAction): - def __init__(self): - super().__init__(name="prometheus", interval=TestnetMonitorActionInterval.EVERY_SLOT) + def __init__(self, interval: TestnetMonitorActionInterval): + super().__init__(name="prometheus", interval=interval) def perform_action(self) -> None: queries = { @@ -183,12 +183,12 @@ def _one_request(key, query): params=dict(query=query) ) if resp.status_code != 200: - logging.info(f"prometheus query {query} responded with status code {resp.status_code}, skipping") + logging.debug(f"prometheus query {query} responded with status code {resp.status_code}, skipping") return result_all = resp.json() if (result_status := result_all["status"]) != "success": - logging.info(f"prometheus query {query} has result status {result_status!r}, skipping") + logging.debug(f"prometheus query {query} has result status {result_status!r}, skipping") return return key, result_all["data"] @@ -196,7 +196,7 @@ def _one_request(key, query): with ThreadPoolExecutor(max_workers=8) as exc: results = dict(exc.map(lambda item: _one_request(*item), queries.items())) - logging.info( + logging( json.dumps({"prometheus_metrics": results}) ) @@ -240,7 +240,8 @@ def build_testnet_monitor(self, cli_args) -> TestnetMonitor: "peers": PeersMonitorAction, "blob": BlobMonitorAction, "execution_availability": HeadsMonitorExecutionAvailabilityCheckAction, - "consensus_availability": HeadsMonitorConsensusAvailabilityCheckAction + "consensus_availability": HeadsMonitorConsensusAvailabilityCheckAction, + "prometheus": PrometheusAction, } intervals = { @@ -256,6 +257,7 @@ def build_testnet_monitor(self, cli_args) -> TestnetMonitor: raise Exception(f"Unknown metric: {metric}") if interval not in intervals: raise Exception(f"Unknown interval: {interval}") + _interval = intervals[interval] testnet_monitor.add_action( @@ -268,8 +270,6 @@ def build_testnet_monitor(self, cli_args) -> TestnetMonitor: ) ) - testnet_monitor.add_action(PrometheusAction()) - return testnet_monitor def get_testnet_info_str(self) -> str: