VictoriaMetrics / grafana-datasource

Grafana Plugin for VictoriaMetrics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support WITH templates

hagen1778 opened this issue · comments

WITH templates in VictoriaMetrics help to simplify complex queries. Would be nice to introduce an option to define global or per-panel expressions, so users can define WITH templates once and then re-use them when needed.

Thanks for #72 @Loori-R!
I think it is already great, but we should polish it a bit.

  • Support comments for WITH template expressions. For example:
# cf filters by job and instance
cf = {job=~"$job", instance=~"$instance"},
# rateBy calculates rate and groups by metric name and group label. Use it instead of rate.
rateBy(metric, group) = sum(rate(metric{cf})) by(group)

When using these expressions in query panel, it would be nice to display the # comments in the popup windows with autosuggestion. So user could read the comment and get more idea about this custom function or filter

  • Allow auto-complete inside curly brackets for filters defined in WITH expressions. In the example above, we defined cf filter. It would be great for plugin to suggest it along with other labels when user opens a curly braces { in query.

  • Add docs to README explaining how to use WITH templates integration. The doc should cover how to define WITH expressions, how to work with comments, how to validate, and how to use defined expressions inside panel queries. Such docs would significantly improve users experience and understanding of this feature.

  • Support Grafana variables such as $__interval, $__rate_interval, etc. in WITH expression validation