Skip to content

Commit

Permalink
Fixing victoria metrics check
Browse files Browse the repository at this point in the history
  • Loading branch information
Avi-Robusta committed Aug 8, 2023
1 parent 563c9b2 commit b7a36cf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class PrometheusMetricsService(MetricsService):
"""

service_discovery: type[MetricsServiceDiscovery] = PrometheusDiscovery
is_victoria_metrics: bool = False

def __init__(
self,
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class VictoriaMetricsService(PrometheusMetricsService):
"""

service_discovery = VictoriaMetricsDiscovery
is_victoria_metrics: bool = True

def check_connection(self):
"""
Expand Down
6 changes: 4 additions & 2 deletions robusta_krr/core/integrations/prometheus/prometheus_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

0 comments on commit b7a36cf

Please sign in to comment.