From b7a36cf780fcdfbf8ffe6bd28ced502269f177ce Mon Sep 17 00:00:00 2001 From: avi robusta Date: Tue, 8 Aug 2023 16:36:38 +0300 Subject: [PATCH] Fixing victoria metrics check --- .../metrics_service/prometheus_metrics_service.py | 3 +-- .../prometheus/metrics_service/victoria_metrics_service.py | 1 - .../core/integrations/prometheus/prometheus_utils.py | 6 ++++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py b/robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py index db94ace4..54805124 100644 --- a/robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py +++ b/robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py @@ -48,7 +48,6 @@ class PrometheusMetricsService(MetricsService): """ service_discovery: type[MetricsServiceDiscovery] = PrometheusDiscovery - is_victoria_metrics: bool = False def __init__( self, @@ -85,7 +84,7 @@ def __init__( elif not self.config.inside_cluster and self.api_client is not None: self.api_client.update_params_for_auth(headers, {}, ["BearerToken"]) self.prom_config = generate_prometheus_config( - config, url=self.url, headers=headers, is_victoria_metrics=self.is_victoria_metrics + config, url=self.url, headers=headers, metrics_service=self ) self.prometheus = get_custom_prometheus_connect(self.prom_config) diff --git a/robusta_krr/core/integrations/prometheus/metrics_service/victoria_metrics_service.py b/robusta_krr/core/integrations/prometheus/metrics_service/victoria_metrics_service.py index 10610873..a0f10100 100644 --- a/robusta_krr/core/integrations/prometheus/metrics_service/victoria_metrics_service.py +++ b/robusta_krr/core/integrations/prometheus/metrics_service/victoria_metrics_service.py @@ -33,7 +33,6 @@ class VictoriaMetricsService(PrometheusMetricsService): """ service_discovery = VictoriaMetricsDiscovery - is_victoria_metrics: bool = True def check_connection(self): """ diff --git a/robusta_krr/core/integrations/prometheus/prometheus_utils.py b/robusta_krr/core/integrations/prometheus/prometheus_utils.py index 3e3b94aa..d4c6fd40 100644 --- a/robusta_krr/core/integrations/prometheus/prometheus_utils.py +++ b/robusta_krr/core/integrations/prometheus/prometheus_utils.py @@ -13,8 +13,10 @@ class ClusterNotSpecifiedException(Exception): def generate_prometheus_config( - config: Config, url: str, headers: dict[str, str], is_victoria_metrics: bool = False + config: Config, url: str, headers: dict[str, str], metrics_service: "PrometheusMetricsService" ) -> PrometheusConfig: + from .metrics_service.victoria_metrics_service import VictoriaMetricsService + baseconfig = { "url": url, "disable_ssl": not config.prometheus_ssl_enabled, @@ -43,6 +45,6 @@ def generate_prometheus_config( # coralogix config if config.coralogix_token: return CoralogixPrometheusConfig(**baseconfig, prometheus_token=config.coralogix_token) - if is_victoria_metrics: + if isinstance(metrics_service, VictoriaMetricsService): return VictoriaMetricsPrometheusConfig(**baseconfig) return PrometheusConfig(**baseconfig)