diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f9a151c31..7cdf500d1de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - Automatically determine the RabbitMQ protocol when possible, and support setting the protocl via TriggerAuthentication ([#1459](https://github.com/kedacore/keda/pulls/1459),[#1483](https://github.com/kedacore/keda/pull/1483)) - Improve performance when fetching pod information ([#1457](https://github.com/kedacore/keda/pull/1457)) - Improve performance when fetching current scaling information on Deployments ([#1458](https://github.com/kedacore/keda/pull/1458)) +- Improve error reporting in prometheus scaler ([PR #1497](https://github.com/kedacore/keda/pull/1497)) ### Breaking Changes diff --git a/pkg/scalers/prometheus_scaler.go b/pkg/scalers/prometheus_scaler.go index 92e31cad8be..b9b8ba53b65 100644 --- a/pkg/scalers/prometheus_scaler.go +++ b/pkg/scalers/prometheus_scaler.go @@ -149,6 +149,10 @@ func (s *prometheusScaler) ExecutePromQuery() (float64, error) { } r.Body.Close() + if !(r.StatusCode >= 200 && r.StatusCode <= 299) { + return -1, fmt.Errorf("prometheus query api returned error. status: %d response: %s", r.StatusCode, string(b)) + } + var result promQueryResult err = json.Unmarshal(b, &result) if err != nil {