Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prometheus scaler throws an error when a query returns empty #657

Closed
jeffhollan opened this issue Mar 8, 2020 · 1 comment · Fixed by #695
Closed

Prometheus scaler throws an error when a query returns empty #657

jeffhollan opened this issue Mar 8, 2020 · 1 comment · Fixed by #695
Labels
bug Something isn't working good first issue Good for newcomers help wanted Looking for support from community scaler-prometheus

Comments

@jeffhollan
Copy link
Member

When using prometheus to do something like scale an HTTP workload, if the requests are nil for that period of time the scaler throws an error every time it polls:

{"level":"error","ts":1583710650.0702486,"logger":"prometheus_scaler","msg":"error executing prometheus query","error":"Prometheus query sum(rate(nginx_ingress_controller_requests{service="java-azure-function-http"}[5s])) returned empty","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/go/pkg/mod/github.com/go-logr/zapr@v0.1.1/zapr.go:128\ngithub.com/kedacore/keda/pkg/scalers.(*prometheusScaler).IsActive\n\tkeda/pkg/scalers/prometheus.go:101\ngithub.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScaleDeployment\n\tkeda/pkg/handler/scale_loop.go:119\ngithub.com/kedacore/keda/pkg/handler.(*ScaleHandler).handleScale\n\tkeda/pkg/handler/scale_loop.go:45\ngithub.com/kedacore/keda/pkg/handler.(*ScaleHandler).HandleScaleLoop\n\tkeda/pkg/handler/scale_loop.go:28"}

Would be good to have the scaler handle an empty query as a 0

@jeffhollan jeffhollan added bug Something isn't working help wanted Looking for support from community good first issue Good for newcomers scaler-prometheus labels Mar 8, 2020
@droessmj
Copy link
Contributor

droessmj commented Mar 20, 2020

are you just looking for this line to be a 0,nil return instead of it's current case or is there a complexity I'm missing?

return -1, fmt.Errorf("Prometheus query %s returned empty", s.metadata.query)

Edit: I did see that I'd need to bubble up zero as a valid return value higher in call stack and did so in the PR.

SpiritZhou pushed a commit to SpiritZhou/keda that referenced this issue Jul 18, 2023
Signed-off-by: amirschw <24677563+amirschw@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Looking for support from community scaler-prometheus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants