grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
23.86k stars 3.44k forks source link

Custom variable in grafana with Stream selector {$label_name=~"$label_value"} is not correct works #12983

Open Vitaliy155 opened 5 months ago

Vitaliy155 commented 5 months ago

Describe the bug Grafana dashboard variable works incorrect where variable definition as {$label_name=~"$label_value"}

To Reproduce

  1. Create 3 variables in the Grafana dashboard: label_name - Query type: Label names; label_value - Query type: Label values, Label: {$label_name}; loglevel - Query type: Label values, Label: loglevel, stream selector: {$label_name=~“$label_value”}

  2. Save and go to dashboard.

  3. Choose Label name:host, Label value: , level: one of the available levels. In my case it's ERROR. There is no level ERROR ... but should be!

Expected behavior Should be available value from custom variables related to label_value. As workaround, you can see label_value: "ERROR" without custom variable if choose: label_name: "loglevel" and label_value: "ERROR"

Environment: Grafana: 10.4.3 Loki:3.0.0

Screenshots, Promtail config, or terminal output 1 2 33 label_loglevel label_name label_value

### Tasks
lux4rd0 commented 4 months ago

Same issue - I have used stream selectors forever to filter logs from labels with variables dynamically, and they seem to get blanked out in the UI when saved - and ignored altogether when filtering additional nested variables.

I have been using this since Loki was released:

label_values(compose_project)   

service
label_values({compose_project=~"$project"}, compose_service)    

container
label_values({compose_project=~"$project", compose_service=~"$service"}, container_name)    

host
label_values({compose_service=~"$service", container_name=~"$container"}, host) 
itsek commented 3 months ago

This Bug basicly breaks chained variables when using loki as a datasouce :( grafik

broferek commented 1 month ago

We are stuck to Grafana 11.0.0 because of this issue. I have tried to upgrade to any newer versions (11.1 or 11.2) and it breaks dashboard chained variables every time.