Skip to content

Commit 6a00963

Browse files
committed
Include HTTP status code in Prometheus error responses
When Prometheus returns an HTTP error (4xx/5xx), the error message now includes the status code and reason phrase. Previously, only the response body was shown, which made it difficult to diagnose issues like HTTP 403 errors caused by missing authorization policies. Fixes #1434 Signed-off-by: rohansood10 <rohansood10@users.noreply.github.com>
1 parent d4cc9bf commit 6a00963

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

pkg/metrics/providers/prometheus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func (p *PrometheusProvider) RunQuery(query string) (float64, error) {
143143
}
144144

145145
if 400 <= r.StatusCode {
146-
return 0, fmt.Errorf("error response: %s", string(b))
146+
return 0, fmt.Errorf("error response: Status %d %s: %s", r.StatusCode, http.StatusText(r.StatusCode), string(b))
147147
}
148148

149149
var result prometheusResponse

0 commit comments

Comments
 (0)