Report
KEDA uses an community integration for LOKI based scaling: https://keda.sh/docs/2.19/scalers/loki/
Internally it tries to use these api endpoints to make query: https://grafana.com/docs/loki/latest/reference/loki-http-api/
But there is another issue inside the loki_scaler community code: https://github.com/kedacore/keda/blob/main/pkg/scalers/loki_scaler.go#L122
here, it overrides the existing url path with /loki/api/v1/query due to which the final url becomes http://<loki-host>:3100/loki/api/v1/query.
it only accepts serverAddress which has a base url like http://<loki-host>:3100, and not any url with sub-path.
If there is a extra sub path to the url,
for eg: http://<company-host>:3100/<product_name>/grafana,
instead of the url becoming http://<company-host>:3100/<product_name>/grafana/loki/api/v1/query,
it becomes http://<company-host>:3100/loki/api/v1/query, which is not correct in our case.
Need help with a workaround.
Expected Behavior
/loki/api/v1/query should be appended at the end of the url.
eg: http://<company-host>:3100/<product_name>/grafana/loki/api/v1/query
Actual Behavior
/loki/api/v1/query overrides the path.
eg: http://<company-host>:3100/loki/api/v1/query
Steps to Reproduce the Problem
- define loki url as
http://<company-host>:3100/<product_name>/grafana
- run loki trigger with this url
<product_name>/grafana gets overriden with /loki/api/v1/query instead of appending as <product_name>/grafana/loki/api/v1/query
Logs from KEDA operator
KEDA Version
2.19.0
Kubernetes Version
1.34
Platform
Microsoft Azure
Scaler Details
Loki scaler https://keda.sh/docs/2.19/scalers/loki/
Would you be open to contributing a fix?
Yes
Anything else?
we can update the path as u.Path = path.Join(u.Path, loki_path) at https://github.com/kedacore/keda/blob/main/pkg/scalers/loki_scaler.go#L122
Report
KEDA uses an community integration for LOKI based scaling: https://keda.sh/docs/2.19/scalers/loki/
Internally it tries to use these api endpoints to make query: https://grafana.com/docs/loki/latest/reference/loki-http-api/
But there is another issue inside the
loki_scalercommunity code: https://github.com/kedacore/keda/blob/main/pkg/scalers/loki_scaler.go#L122here, it overrides the existing url path with
/loki/api/v1/querydue to which the final url becomeshttp://<loki-host>:3100/loki/api/v1/query.it only accepts
serverAddresswhich has a base url likehttp://<loki-host>:3100, and not any url with sub-path.If there is a extra sub path to the url,
for eg:
http://<company-host>:3100/<product_name>/grafana,instead of the url becoming
http://<company-host>:3100/<product_name>/grafana/loki/api/v1/query,it becomes
http://<company-host>:3100/loki/api/v1/query, which is not correct in our case.Need help with a workaround.
Expected Behavior
/loki/api/v1/queryshould be appended at the end of the url.eg:
http://<company-host>:3100/<product_name>/grafana/loki/api/v1/queryActual Behavior
/loki/api/v1/queryoverrides the path.eg:
http://<company-host>:3100/loki/api/v1/querySteps to Reproduce the Problem
http://<company-host>:3100/<product_name>/grafana<product_name>/grafanagets overriden with/loki/api/v1/queryinstead of appending as<product_name>/grafana/loki/api/v1/queryLogs from KEDA operator
KEDA Version
2.19.0
Kubernetes Version
1.34
Platform
Microsoft Azure
Scaler Details
Loki scaler https://keda.sh/docs/2.19/scalers/loki/
Would you be open to contributing a fix?
Yes
Anything else?
we can update the path as
u.Path = path.Join(u.Path, loki_path)at https://github.com/kedacore/keda/blob/main/pkg/scalers/loki_scaler.go#L122