Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable substitution in promql #35

Closed
rgeyer opened this issue Apr 1, 2022 · 0 comments
Closed

Variable substitution in promql #35

rgeyer opened this issue Apr 1, 2022 · 0 comments

Comments

@rgeyer
Copy link
Collaborator

rgeyer commented Apr 1, 2022

It is perfectly valid for promql to use global, and dashboard templated variables throughout, including in range vector selectors.

Currently, promql which makes use of this will fail. An example is in the kubernetes mixin, on the network panels, this is used heavily in the form of [$interval:$resolution] and results in errors like the one shown below.

[panel-promql-rule] 'Kubernetes / Networking / Cluster': Dashboard 'Kubernetes / Networking / Cluster', panel 'Rate of TCP Retransmits out of all sent segments' invalid PromQL query 'sort_desc(sum(rate(node_netstat_Tcp_RetransSegs{cluster="$cluster"}[$interval:$resolution]) / rate(node_netstat_Tcp_OutSegs{cluster="$cluster"}[$interval:$resolution])) by (instance))': 1:69: parse error: bad duration syntax: ""

The linter should replace all global variables with a sane/unique value which can be validated against.

The linter should also replace all dashboard templated variables with a sane placeholder value, allowing it to be properly evaluated as promql.

This was solved in the closed-source iteration of this dashboard linter in https://github.com/grafana/cloud-onboarding/pull/412, and something similar should be implemented here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant