diff options
| author | avi robusta <avi@robusta.dev> | 2023-06-14 12:30:54 +0300 |
|---|---|---|
| committer | avi robusta <avi@robusta.dev> | 2023-06-14 12:30:54 +0300 |
| commit | 84f9f58973f00a804b6c11ad6e3c8ec3ae5d48b5 (patch) | |
| tree | d0b62946ff2f3282a362dd636337feacf46deb09 | |
| parent | 31a192559010bb72e962844183a0a8bd4f83c5e9 (diff) | |
support custom label name
the standard is cluster
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | robusta_krr/core/integrations/prometheus/metrics/base_metric.py | 2 | ||||
| -rw-r--r-- | robusta_krr/core/models/config.py | 1 | ||||
| -rw-r--r-- | robusta_krr/main.py | 7 |
4 files changed, 15 insertions, 1 deletions
@@ -334,6 +334,12 @@ For example, if your cluster has the Prometheus label `cluster: "my-cluster-name krr.py simple -p http://my-centralized-prometheus:9090 -l my-cluster-name ``` +If you are using a label 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 +``` + <p align="right">(<a href="#readme-top">back to top</a>)</p> <!-- Formatters --> diff --git a/robusta_krr/core/integrations/prometheus/metrics/base_metric.py b/robusta_krr/core/integrations/prometheus/metrics/base_metric.py index aea633c..47d33d2 100644 --- a/robusta_krr/core/integrations/prometheus/metrics/base_metric.py +++ b/robusta_krr/core/integrations/prometheus/metrics/base_metric.py @@ -39,7 +39,7 @@ class BaseMetricLoader(Configurable, abc.ABC): """ if self.config.prometheus_cluster_label is None: return "" - return f', cluster="{self.config.prometheus_cluster_label}"' + return f', {self.config.prometheus_label}="{self.config.prometheus_cluster_label}"' @abc.abstractmethod def get_query(self, object: K8sObjectData) -> str: diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py index 72cf4d8..22a5d41 100644 --- a/robusta_krr/core/models/config.py +++ b/robusta_krr/core/models/config.py @@ -26,6 +26,7 @@ class Config(pd.BaseSettings): prometheus_auth_header: Optional[str] = pd.Field(None) prometheus_ssl_enabled: bool = pd.Field(False) prometheus_cluster_label: Optional[str] = pd.Field(None) + prometheus_label: Optional[str] = pd.Field(None) # Logging Settings format: str diff --git a/robusta_krr/main.py b/robusta_krr/main.py index 33480e9..968557a 100644 --- a/robusta_krr/main.py +++ b/robusta_krr/main.py @@ -98,6 +98,12 @@ def load_commands() -> None: help="The label in prometheus for your cluster.(Only relevant for centralized prometheus)", rich_help_panel="Prometheus Settings", ), + prometheus_label: Optional[str] = typer.Option( + 'cluster', + "--prometheus-label", + help="The label in prometheus used to differentiate clusters. (Only relevant for centralized prometheus)", + rich_help_panel="Prometheus Settings", + ), format: str = typer.Option("table", "--formatter", "-f", help="Output formatter ({formatters})", rich_help_panel="Logging Settings"), verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose mode", rich_help_panel="Logging Settings"), quiet: bool = typer.Option(False, "--quiet", "-q", help="Enable quiet mode", rich_help_panel="Logging Settings"), @@ -114,6 +120,7 @@ def load_commands() -> None: prometheus_auth_header=prometheus_auth_header, prometheus_ssl_enabled=prometheus_ssl_enabled, prometheus_cluster_label=prometheus_cluster_label, + prometheus_label=prometheus_label, format=format, verbose=verbose, quiet=quiet, |
