grafana / mimir

Grafana Mimir provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus.
https://grafana.com/oss/mimir/
GNU Affero General Public License v3.0
3.96k stars 498 forks source link

Mimirtool fails parsing expressions with a dashboard variable in a comparison #8734

Open cydergoth opened 1 month ago

cydergoth commented 1 month ago

Describe the bug

Given an expression such as "query=sum(rabbitmq_queue_messages{ tenant=~\"$tenant\"}) by (tenant, queue) \u003e $threshold: 1:238: parse error: unexpected character: '$'" Mimirtool is failing to parse the expression as per this error from the metrics-in-grafana.json file (ascii \u003e is >)

To Reproduce

Build a dashboard JSON containing a query which uses a dashboard variable in a comparison, then attempt to report on it with

 mimirtool analyze dashboard *.json

Observe an error similar to the above in the output metrics-in-grafana.json file

Expected behavior

The query is parsed correctly

Environment

N/A

Additional Context

$ mimirtool version Mimirtool, version 2.9.0 (branch: release-2.9, revision: 761114d8b) go version: go1.20.5 platform: linux/amd64

cydergoth commented 1 month ago

Also verified with 2.12.0