summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchengzw <40051120+cr7258@users.noreply.github.com>2023-07-18 19:01:48 +0800
committerGitHub <noreply@github.com>2023-07-18 14:01:48 +0300
commit06f7f960672618f4cc76bf7f7213e310861ac06e (patch)
tree7afa2f0613ef22eeeaeae222da4a7f213c492aaa
parentc971ee7bb0767f9713260d4fc92b7ad8d9b74d30 (diff)
Set default value of prometheus_label to None (#101)
* set default value of prometheus_label to None * update doc * optimize validate_cluster_name check logic
-rw-r--r--README.md8
-rw-r--r--robusta_krr/core/integrations/prometheus/metrics_service/prometheus_metrics_service.py3
-rw-r--r--robusta_krr/core/models/config.py2
-rw-r--r--robusta_krr/main.py2
4 files changed, 6 insertions, 9 deletions
diff --git a/README.md b/README.md
index a465f6b..677354c 100644
--- a/README.md
+++ b/README.md
@@ -357,13 +357,7 @@ If your Prometheus monitors multiple clusters we require the label you defined f
For example, if your cluster has the Prometheus label `cluster: "my-cluster-name"` and your prometheus is at url `http://my-centralized-prometheus:9090`, then run this command:
```sh
-krr.py simple -p http://my-centralized-prometheus:9090 -l my-cluster-name
-```
-
-If you are using a label for your cluster other than `cluster` for example the label `env: "dev-tests"` you can specify it by running:
-
-```sh
-krr.py simple -p http://my-centralized-prometheus:9090 --prometheus-label env -l dev-tests
+krr.py simple -p http://my-centralized-prometheus:9090 --prometheus-label cluster -l my-cluster-name
```
<p align="right">(<a href="#readme-top">back to top</a>)</p>
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 ecc3e5d..5b22472 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
@@ -117,6 +117,9 @@ class PrometheusMetricsService(MetricsService):
return await loop.run_in_executor(self.executor, lambda: self.prometheus.custom_query(query=query))
def validate_cluster_name(self):
+ if not self.config.prometheus_cluster_label and not self.config.prometheus_label:
+ return
+
cluster_label = self.config.prometheus_cluster_label
cluster_names = self.get_cluster_names()
diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py
index 61c8b4f..36eb152 100644
--- a/robusta_krr/core/models/config.py
+++ b/robusta_krr/core/models/config.py
@@ -28,7 +28,7 @@ class Config(pd.BaseSettings):
prometheus_other_headers: dict[str, str] = pd.Field(default_factory=dict)
prometheus_ssl_enabled: bool = pd.Field(False)
prometheus_cluster_label: Optional[str] = pd.Field(None)
- prometheus_label: str = pd.Field("cluster")
+ prometheus_label: Optional[str] = pd.Field(None)
# Threading settings
max_workers: int = pd.Field(6, ge=1)
diff --git a/robusta_krr/main.py b/robusta_krr/main.py
index 05966ee..db97433 100644
--- a/robusta_krr/main.py
+++ b/robusta_krr/main.py
@@ -113,7 +113,7 @@ def load_commands() -> None:
rich_help_panel="Prometheus Settings",
),
prometheus_label: str = typer.Option(
- 'cluster',
+ None,
"--prometheus-label",
help="The label in prometheus used to differentiate clusters. (Only relevant for centralized prometheus)",
rich_help_panel="Prometheus Settings",