From 3a202f7b52fcde0847c0e628a9f73799e9fb02c6 Mon Sep 17 00:00:00 2001 From: sametd Date: Wed, 20 Dec 2023 19:43:26 +0100 Subject: [PATCH] metric token support added for retrieve metrics function --- .../aviso_monitoring/reporter/opsview_reporter.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aviso-server/monitoring/aviso_monitoring/reporter/opsview_reporter.py b/aviso-server/monitoring/aviso_monitoring/reporter/opsview_reporter.py index 4dd81c9..14d7be6 100644 --- a/aviso-server/monitoring/aviso_monitoring/reporter/opsview_reporter.py +++ b/aviso-server/monitoring/aviso_monitoring/reporter/opsview_reporter.py @@ -202,7 +202,8 @@ def aggregate_unique_counter_tlms(tlms): } return agg_tlm - def retrieve_metrics(self, metric_servers, req_timeout): + @classmethod + def retrieve_metrics(cls, metric_servers, req_timeout): """ This methods retrieves the metrics provided by specific metric servers using a Prometheus interface. """ @@ -212,8 +213,8 @@ def retrieve_metrics(self, metric_servers, req_timeout): logger.debug(f"Retrieving metrics from {url}...") headers = {} try: - if self.metric_ssl_enabled: - headers["Authorization"] = f"Bearer {self.metric_token}" + if cls.metric_ssl_enabled: + headers["Authorization"] = f"Bearer {cls.metric_token}" resp = requests.get(url, verify=False, timeout=req_timeout, headers=headers) except Exception as e: logger.exception(f"Not able to get metrics from {url}, error {e}")