grafana / alloy

OpenTelemetry Collector distribution with programmable pipelines
https://grafana.com/oss/alloy
Apache License 2.0
1.27k stars 172 forks source link

Broken alloy-logs JSON in alloy-mixin #1307

Open kshitijmjoshi opened 1 month ago

kshitijmjoshi commented 1 month ago

What's wrong?

The JSON generated from https://github.com/grafana/alloy/blob/main/operations/alloy-mixin/dashboards/alloy-logs.libsonnet is broken and throws an error Status: 500. Message: parse error at line 1, col 34: syntax error: unexpected ,, expecting IDENTIFIER or } when imported into grafana.

There is a extra trailing comma in the queries. Example: Output is label_values({,cluster=~"$cluster",namespace=~"$namespace"}, job) instead of label_values({cluster=~"$cluster",namespace=~"$namespace"}, job)

It seems to be coming from these 2 lines from the logs-lib library https://github.com/grafana/jsonnet-libs/blob/master/logs-lib/logs/variables.libsonnet#L55C8-L55C13 and https://github.com/grafana/jsonnet-libs/blob/master/logs-lib/utils.libsonnet#L21

It can be fixed by removing the comma in those files in /vendor/logs-libbut I don't know what implications it might have if I raise a PR to the library repo.

Steps to reproduce

brew install jsonnet && brew install jsonnet-bundler git clone https://github.com/grafana/alloy and cd operations/alloy-mixin. sudo curl -fSL -o "/usr/local/bin/grr" "https://github.com/grafana/grizzly/releases/download/v0.4.3/grr-darwin-arm64" sudo chmod a+x "/usr/local/bin/grr" grr config set only-spec true jb install grr export grizzly.jsonnet output -o json

Import the output/Dashboards/53c1ecddc3a1d5d4b8d6cd0c23676c31.json file in grafana

It can be fixed by removing the comma at these 2 places in the /vendor folder. https://github.com/grafana/jsonnet-libs/blob/master/logs-lib/logs/variables.libsonnet#L55C8-L55C13 and https://github.com/grafana/jsonnet-libs/blob/master/logs-lib/utils.libsonnet#L21

System information

Apple M2 Max

Software version

No response

Configuration

No response

Logs

No response

### Tasks
github-actions[bot] commented 3 weeks ago

This issue has not had any activity in the past 30 days, so the needs-attention label has been added to it. If the opened issue is a bug, check to see if a newer release fixed your issue. If it is no longer relevant, please feel free to close this issue. The needs-attention label signals to maintainers that something has fallen through the cracks. No action is needed by you; your issue will be kept open and you do not have to respond to this comment. The label will be removed the next time this job runs if there is new activity. Thank you for your contributions!