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

Add meta-variable for better templating experience #16694

Closed
wants to merge 2 commits into from

Conversation

hagen1778
Copy link
Contributor

Meta-variable allows to reference already declared variables
which gives additional flexibility in queries.

What this PR does / why we need it:
Meta-variable allows to reference already declared variables which gives additional flexibility in queries. For example, create variable commonFilter with following content: region=~"$region", instance=~"$instance", where region and instance were already declared. Then we can use meta-variable in query: up{$commonFilter}.

Which issue(s) this PR fixes:
Fixes #16582

Meta-variable allows to reference already declared variables
which gives additional flexibility in queries. Such as declaring
common filters, creating dynamic queries or using CTE extensions
in databases like VictoriaMetrics.
@hagen1778
Copy link
Contributor Author

hagen1778 commented Apr 24, 2019

Meta-variables could significantly simplify dashboards building process. Let's take nodeexporter dashboard:
ne_1
We see that filter instance=~"$node:$port",job=~"$job" repeats in queries. To be honest, this filter used 501 times in that dashboard. And if someone wants to change it, the best way will be to export dashboard to json and do search&replace.

Or someone can use meta-variable:
ne_2
ne_3

It is easy now to change common filter for all panels on the dashboard by modifying just one variable. Using this approach also protects from copy&paste errors.

@valyala
Copy link

valyala commented May 7, 2019

Are there any updates on this PR? cc'ing @torkelo .

@hagen1778
Copy link
Contributor Author

Hi @torkelo! Can I have some response regarding PR or issue?

@torkelo
Copy link
Member

torkelo commented Jun 4, 2019

Not sure this is the best solution for the underlying problem, maybe some kind of query template feature would solve this better?

@valyala
Copy link

valyala commented Jun 4, 2019

Not sure this is the best solution for the underlying problem, maybe some kind of query template feature would solve this better?

@torkelo , could you elaborate on query template feature? Template meta-vars may be applied to any data source or query language.

@hagen1778
Copy link
Contributor Author

Query template doesn't help when you need to modify all existing queries. The only possible way to do it in "easy" way is to export dashboard in json and do find&replace in some editor.
However, meta-variable can be used not for common filters only. Moreover, as @valyala mentioned meta-variables may be used with any datasource, which is simple and transparent for users.
If you have concerns regarding to implementation I would be happy to make it better.

@stale
Copy link

stale bot commented Dec 3, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale Issue with no recent activity label Dec 3, 2019
@valyala
Copy link

valyala commented Dec 3, 2019

@torkelo , are there any decision updates on this pull request?

@stale stale bot removed the stale Issue with no recent activity label Dec 3, 2019
@stale
Copy link

stale bot commented Dec 17, 2019

This pull request has been automatically marked as stale because it has not had activity in the last 2 weeks. It will be closed in 30 days if no further activity occurs. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

@stale stale bot added the stale Issue with no recent activity label Dec 17, 2019
@stale
Copy link

stale bot commented Jan 17, 2020

This pull request has been automatically closed because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, or re-open when it's ready. Thank you for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dashboard/templating area/frontend pr/external This PR is from external contributor stale Issue with no recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FeatureRequest] Variables - Add template variable type
4 participants