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

templating/selection does not work as expected. #14

Closed
samuelbenhamou opened this issue May 25, 2016 · 3 comments
Closed

templating/selection does not work as expected. #14

samuelbenhamou opened this issue May 25, 2016 · 3 comments

Comments

@samuelbenhamou
Copy link

Hi,
I am not sure it is an issue or if the system is working as intended so take it as is.

I installed grafana /kairos/cassandra on different nodes. Played with it and so far so good; except for a small issue.
I am reporting metrics through collectd and added a template variable called host which I expected would help me filter my dashboard by host. Basically doing that in grafana :
$host tag_values(collectd.cpu.percent.active.value,host)

After I added this, the dashboard displayed a nice dropdown to help me select my hosts.

Now, coming to the graph itself, I expected to be able to specify this :
Metric collectd.cpu.percent.active.value
Tags host = ["$host"]
Group By tags: host

and it did not work as tracking down the plugin js I noticed that grafana is sending an array with only one index containing all expanded values.
Let's say I have 3 hosts, h1,h2,h3
it ended up with passing query.tags['host'][0]="{h1,h2,h3}" (datasource.js:340) which kairos could not evaluate. It should pass query.tags['host'][0]="h1",query.tags['host'][1]="h2"...

I just dirty patched it to make it work as I expected and now can select my hosts from the dropdown and get the selection working :

datasource.js:337

if (target.tags) {
      query.tags = angular.copy(target.tags);
      _.forOwn(query.tags, function(value, key) {
           query.tags[key] = _.map(value, function(tag) { return self.templateSrv.replace(tag); });
           var tmp=[];
           query.tags[key].forEach(function(subtag,index,qu_tag) {
                tmp=tmp.concat(subtag.replace(/{|}/g,'').split(","));
           });
           query.tags[key]=tmp;
      });
}
@jifwin
Copy link
Contributor

jifwin commented Jul 5, 2016

+1

@jifwin
Copy link
Contributor

jifwin commented Jul 7, 2016

In my opinion returning an object or array should be supported by Grafana's templateSrv, not the plugins itself. I've created a feature request in Grafana repository (grafana/grafana#5532)

@jifwin
Copy link
Contributor

jifwin commented Jan 30, 2017

This should be fixed a while ago. Otherwise please reopen.

@jifwin jifwin closed this as completed Jan 30, 2017
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

2 participants