summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Zhukov <33721692+LeaveMyYard@users.noreply.github.com>2024-03-04 10:34:47 +0200
committerGitHub <noreply@github.com>2024-03-04 10:34:47 +0200
commita203eaf274d03a8d64d7e0401ab36f67f2817112 (patch)
tree08a048c12ec63f74ee51b35f332583ff54c7280e
parentae80181ccc5128caf93fe6acc4b47ca137263e25 (diff)
parent70263c4afdd525cf9f69025bada5fc468a4a67c4 (diff)
Merge pull request #221 from robusta-dev/improve-dx-for-prometheus-url
Warn the user if prometheus_url is in wrong format
-rw-r--r--robusta_krr/core/models/config.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/robusta_krr/core/models/config.py b/robusta_krr/core/models/config.py
index 54a9ed3..0f22854 100644
--- a/robusta_krr/core/models/config.py
+++ b/robusta_krr/core/models/config.py
@@ -74,6 +74,16 @@ class Config(pd.BaseSettings):
def Formatter(self) -> formatters.FormatterFunc:
return formatters.find(self.format)
+ @pd.validator("prometheus_url")
+ def validate_prometheus_url(cls, v: Optional[str]):
+ if v is None:
+ return None
+
+ if not v.startswith("https://") and not v.startswith("http://"):
+ raise Exception("--prometheus-url must start with https:// or http://")
+
+ return v
+
@pd.validator("prometheus_other_headers", pre=True)
def validate_prometheus_other_headers(cls, headers: Union[list[str], dict[str, str]]) -> dict[str, str]:
if isinstance(headers, dict):