We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7bd8646 commit 8b5e069Copy full SHA for 8b5e069
ocp_utilities/monitoring.py
@@ -144,10 +144,10 @@ def get_scrape_interval(self) -> int:
144
response = self._get_response(query=f"{self.api_v1}/targets")
145
result = response.get("data", {}).get("activeTargets", [])
146
for item in result:
147
- if item and item["labels"]["job"] == "prometheus-k8s":
148
- scrape_interval = item["scrapeInterval"]
149
- if scrape_interval_match := re.match(r"\d+", scrape_interval):
150
- return int(scrape_interval_match.group())
+ if item and item.get("labels", {}).get("job") == "prometheus-k8s":
+ if scrape_interval := item.get("scrapeInterval"):
+ if scrape_interval_match := re.match(r"\d+", scrape_interval):
+ return int(scrape_interval_match.group())
151
152
return 30
153
0 commit comments