Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Template variables in aggregators #67

Open
fbeneventi opened this issue Apr 20, 2018 · 10 comments
Open

Template variables in aggregators #67

fbeneventi opened this issue Apr 20, 2018 · 10 comments

Comments

@fbeneventi
Copy link

fbeneventi commented Apr 20, 2018

Hi,

I need to use a template variable in an aggregator expression as for example:

$N = 24

and then in aggregator I try to do:

scale($N)

where $N is a "custom" type template variable.

Executing this query I have the following error:

query.metric[1].aggregators[1].factor For input string: "$N"

It seems that variables are not interpolated in aggregators. Is there a way/plan to do this?

thanks!
Francesco

@jifwin
Copy link
Contributor

jifwin commented Apr 21, 2018

Hi Francesco
Thanks for reporting that. Would you submit a PR?

@gucharbon
Copy link

@jifwin We are also really interested in this feature ! Do you think this represent a big effort ? I was able to do that like 1 month ago but I don't remember which datasource or Grafana version I was using.
I can try investigating as we need this feature in our project.

@jifwin
Copy link
Contributor

jifwin commented Jul 11, 2018

Templating of aggregators parameters is a bit more tricky, but definitely doable. The question is how to handle multi-value variables with many aggregators defined. E.g.

var1=[1,2,3], AVG($var1,HOUR) + MAX($var1, HOUR)
Would you expect 9 series (cartesian) or 3 (1-to-1 matching)?

Or maybe multivalue variables shouldn't be allowed allowed at all?

@gucharbon
Copy link

I'm not sure I understood your point.
I'm okay with not allowing multi variables for variable in Aggregators.
If we wanted to create several visualizations based on each unit or value of aggregator it would make sense, but this seems far too complicated and not really useful.
We would already gain an awesome feature if we could use Single variable in aggregators

@fbeneventi
Copy link
Author

Yes, currently only "custom" variables seem not working in aggregators and for now it should be ok to support just single value variables.

@gucharbon
Copy link

Oh really ? That means that if I use any other variable, like store my desired Units in a mysql table I can query them and use them in the query builder ? I didn't know that

@jifwin
Copy link
Contributor

jifwin commented Jul 11, 2018

I don't think so. It doesn't matter what type of variable it is.

@jifwin
Copy link
Contributor

jifwin commented Jul 11, 2018

@gucharbon Are you OK with support for single-value variables?

@gucharbon
Copy link

@jifwin Definitely ! 👍

@fbeneventi
Copy link
Author

Sorry,
I was talking about the old version (v2.0.1) where I switched to. Also there, custom variables does not work. Other variables I need (Interval) work perfectly in aggregators in v2.0.1, but I found they do not in the latest version.
If it is possible to restore also this kind of variable it would be great!
Thanks!

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

No branches or pull requests

3 participants