From eca1bc78bab5743912704f1f4a6fc625e31c5606 Mon Sep 17 00:00:00 2001 From: nhnn Date: Sat, 13 Jul 2024 22:04:02 +0300 Subject: [PATCH] fix: change _send_query to make use of 'data' field in response of prometheus --- selfprivacy_api/utils/prometheus.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/selfprivacy_api/utils/prometheus.py b/selfprivacy_api/utils/prometheus.py index ab816be..80a09fe 100644 --- a/selfprivacy_api/utils/prometheus.py +++ b/selfprivacy_api/utils/prometheus.py @@ -36,8 +36,11 @@ class PrometheusQueries: if response.status_code != 200: raise Exception("Prometheus returned unexpected HTTP status code") json = response.json() + if json['status'] != 'success': + raise Exception("Prometheus returned unexpected status") + result = json['data'] return PrometheusQueryResult( - result_type=json['result_type'], result=json['result'] + result_type=result['result_type'], result=result['result'] ) except Exception as error: raise Exception("Prometheus request failed! " + str(error))