summaryrefslogtreecommitdiff
path: root/robusta_krr
diff options
context:
space:
mode:
authorLeaveMyYard <zhukovpavel2001@gmail.com>2024-04-30 19:14:55 +0300
committerLeaveMyYard <zhukovpavel2001@gmail.com>2024-04-30 19:14:55 +0300
commit59cc29da2174f6c1245f0fa6a9832466d74d68d5 (patch)
tree51f412e0f8a6e1c1dc1511c8a599d3da0bc729bc /robusta_krr
parentf7d841278afe46fe3b21da64ca57691b44670ab4 (diff)
Fix prometheus auto-discovery
Diffstat (limited to 'robusta_krr')
-rw-r--r--robusta_krr/core/integrations/kubernetes/cluster_loader/__init__.py5
-rw-r--r--robusta_krr/core/integrations/prometheus/metrics_service/mimir_metrics_service.py2
-rw-r--r--robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py2
-rw-r--r--robusta_krr/core/integrations/prometheus/metrics_service/thanos_metrics_service.py2
-rw-r--r--robusta_krr/core/integrations/prometheus/metrics_service/victoria_metrics_service.py2
-rw-r--r--robusta_krr/utils/service_discovery.py2
6 files changed, 8 insertions, 7 deletions
diff --git a/robusta_krr/core/integrations/kubernetes/cluster_loader/__init__.py b/robusta_krr/core/integrations/kubernetes/cluster_loader/__init__.py
index ab520bb..b7e86d8 100644
--- a/robusta_krr/core/integrations/kubernetes/cluster_loader/__init__.py
+++ b/robusta_krr/core/integrations/kubernetes/cluster_loader/__init__.py
@@ -51,7 +51,6 @@ class KubeAPIClusterLoader(BaseClusterLoader):
logger.error("Alternatively, try a prometheus-only mode with `--mode prometheus`")
raise CriticalRunnerException("Could not load kubernetes configuration") from e
- self.api_client = settings.get_kube_client()
self._prometheus_connectors: dict[Optional[str], PrometheusConnector] = {}
async def list_clusters(self) -> Optional[list[str]]:
@@ -99,7 +98,9 @@ class KubeAPIClusterLoader(BaseClusterLoader):
connector.connect(settings.prometheus_url)
else:
logger.info(f"Trying to discover PromQL service" + (f" for cluster {cluster}" if cluster else ""))
- connector.discover(api_client=self.api_client)
+ connector.discover(api_client=settings.get_kube_client(cluster))
+
+ return connector
class KubeAPIWorkloadLoader(BaseWorkloadLoader, IListPodsFallback):
diff --git a/robusta_krr/core/integrations/prometheus/metrics_service/mimir_metrics_service.py b/robusta_krr/core/integrations/prometheus/metrics_service/mimir_metrics_service.py
index e11d705..05bbc70 100644
--- a/robusta_krr/core/integrations/prometheus/metrics_service/mimir_metrics_service.py
+++ b/robusta_krr/core/integrations/prometheus/metrics_service/mimir_metrics_service.py
@@ -9,7 +9,7 @@ from .prometheus_metrics_service import PrometheusMetricsService
class MimirMetricsDiscovery(MetricsServiceDiscovery):
- def find_metrics_url(self, *, api_client: Optional[ApiClient] = None) -> Optional[str]:
+ def find_metrics_url(self) -> Optional[str]:
"""
Finds the Mimir Metrics URL using selectors.
Args:
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 08fd83f..9895169 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
@@ -26,7 +26,7 @@ logger = logging.getLogger("krr")
class PrometheusDiscovery(MetricsServiceDiscovery):
- def find_metrics_url(self, *, api_client: Optional[ApiClient] = None) -> Optional[str]:
+ def find_metrics_url(self) -> Optional[str]:
"""
Finds the Prometheus URL using selectors.
Args:
diff --git a/robusta_krr/core/integrations/prometheus/metrics_service/thanos_metrics_service.py b/robusta_krr/core/integrations/prometheus/metrics_service/thanos_metrics_service.py
index eaf1620..4a3dea1 100644
--- a/robusta_krr/core/integrations/prometheus/metrics_service/thanos_metrics_service.py
+++ b/robusta_krr/core/integrations/prometheus/metrics_service/thanos_metrics_service.py
@@ -9,7 +9,7 @@ from .prometheus_metrics_service import PrometheusMetricsService
class ThanosMetricsDiscovery(MetricsServiceDiscovery):
- def find_metrics_url(self, *, api_client: Optional[ApiClient] = None) -> Optional[str]:
+ def find_metrics_url(self) -> Optional[str]:
"""
Finds the Thanos URL using selectors.
Args:
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 e8fbcd0..f2c4690 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
@@ -9,7 +9,7 @@ from .prometheus_metrics_service import PrometheusMetricsService
class VictoriaMetricsDiscovery(MetricsServiceDiscovery):
- def find_metrics_url(self, *, api_client: Optional[ApiClient] = None) -> Optional[str]:
+ def find_metrics_url(self) -> Optional[str]:
"""
Finds the Victoria Metrics URL using selectors.
Args:
diff --git a/robusta_krr/utils/service_discovery.py b/robusta_krr/utils/service_discovery.py
index 5f4853e..056ce1b 100644
--- a/robusta_krr/utils/service_discovery.py
+++ b/robusta_krr/utils/service_discovery.py
@@ -89,5 +89,5 @@ class ServiceDiscovery:
class MetricsServiceDiscovery(ServiceDiscovery, ABC):
@abstractmethod
- def find_metrics_url(self, *, api_client: Optional[ApiClient] = None) -> Optional[str]:
+ def find_metrics_url(self) -> Optional[str]:
pass