Skip to content

Loki Trigger Server Address doesn't support sub path #7646

Description

@pawan-regoti

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

  1. define loki url as http://<company-host>:3100/<product_name>/grafana
  2. run loki trigger with this url
  3. <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

example

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

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Ready To Ship

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions