Merge "Raise CollectError when Prometheus query returns an error"

This commit is contained in:
Zuul 2022-06-01 09:12:11 +00:00 committed by Gerrit Code Review
commit 9f361499fc
2 changed files with 10 additions and 0 deletions

View File

@ -219,6 +219,11 @@ class PrometheusCollector(collector.BaseCollector):
except PrometheusResponseError as e:
raise CollectError(*e.args)
if res['status'] == 'error':
error_type = res['errorType']
error_msg = res['error']
raise CollectError("%s: %s" % (error_type, error_msg))
# If the query returns an empty dataset,
# return an empty list
if not res['data']['result']:

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Raises a ``CollectError`` exception with error details when a Prometheus
query returns an error status.