{"action":"created","issue":{"url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin/issues/15","repository_url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin","labels_url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin/issues/15/comments","events_url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin/issues/15/events","html_url":"https://github.com/grafana-druid-plugin/druidplugin/issues/15","id":232466130,"number":15,"title":"Custom templates do not work in Graph -> Matrics","user":{"login":"CarsonCao","id":23180912,"avatar_url":"https://avatars1.githubusercontent.com/u/23180912?v=3","gravatar_id":"","url":"https://api.github.com/users/CarsonCao","html_url":"https://github.com/CarsonCao","followers_url":"https://api.github.com/users/CarsonCao/followers","following_url":"https://api.github.com/users/CarsonCao/following{/other_user}","gists_url":"https://api.github.com/users/CarsonCao/gists{/gist_id}","starred_url":"https://api.github.com/users/CarsonCao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CarsonCao/subscriptions","organizations_url":"https://api.github.com/users/CarsonCao/orgs","repos_url":"https://api.github.com/users/CarsonCao/repos","events_url":"https://api.github.com/users/CarsonCao/events{/privacy}","received_events_url":"https://api.github.com/users/CarsonCao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-31T06:28:42Z","updated_at":"2017-05-31T17:17:52Z","closed_at":null,"body":"I created a custom template variable named 'items' with values 'url' and 'ip'. And I wanted to use it in dimension of matrics  in order to  allow the graph to dynamically display different information. But it does not work. \r\nHowever ,the template variable in title works well.\r\n\r\nThe panel JSON like below.\r\n----------------------------------------------\r\n{\r\n  \"aliasColors\": {},\r\n  \"bars\": true,\r\n  \"dashLength\": 10,\r\n  \"dashes\": false,\r\n  \"datasource\": \"druid_test\",\r\n  \"fill\": 1,\r\n  \"id\": 2,\r\n  \"legend\": {\r\n    \"alignAsTable\": true,\r\n    \"avg\": false,\r\n    \"current\": false,\r\n    \"max\": false,\r\n    \"min\": false,\r\n    \"rightSide\": true,\r\n    \"show\": true,\r\n    \"total\": false,\r\n    \"values\": false\r\n  },\r\n  \"lines\": false,\r\n  \"linewidth\": 1,\r\n  \"links\": [],\r\n  \"nullPointMode\": \"null\",\r\n  \"percentage\": false,\r\n  \"pointradius\": 5,\r\n  \"points\": false,\r\n  \"renderer\": \"flot\",\r\n  \"repeat\": null,\r\n  \"seriesOverrides\": [],\r\n  \"spaceLength\": 10,\r\n  \"span\": 12,\r\n  \"stack\": false,\r\n  \"steppedLine\": false,\r\n  \"targets\": [\r\n    {\r\n      \"aggregators\": [\r\n        {\r\n          \"fieldName\": \"counts\",\r\n          \"name\": \"counts\",\r\n          \"type\": \"longSum\"\r\n        }\r\n      ],\r\n      \"currentAggregator\": {\r\n        \"type\": \"count\"\r\n      },\r\n      \"currentFilter\": {\r\n        \"type\": \"selector\"\r\n      },\r\n      \"currentPostAggregator\": {\r\n        \"fn\": \"+\",\r\n        \"type\": \"arithmetic\"\r\n      },\r\n      \"currentSelect\": {\r\n        \"dimension\": \"\",\r\n        \"metric\": \"\"\r\n      },\r\n      \"customGranularity\": \"all\",\r\n      \"dimension\": \"$items\",\r\n      \"druidDS\": \"url_ip_test\",\r\n      \"druidMetric\": \"counts\",\r\n      \"errors\": {\r\n        \"aggregators\": \"You must supply at least one aggregator\"\r\n      },\r\n      \"limit\": 10,\r\n      \"queryType\": \"topN\",\r\n      \"refId\": \"A\",\r\n      \"shouldOverrideGranularity\": true\r\n    }\r\n  ],\r\n  \"thresholds\": [],\r\n  \"timeFrom\": \"$timeRange\",\r\n  \"timeShift\": null,\r\n  \"title\": \"[[items]] top10\",\r\n  \"tooltip\": {\r\n    \"shared\": false,\r\n    \"sort\": 0,\r\n    \"value_type\": \"individual\"\r\n  },\r\n  \"type\": \"graph\",\r\n  \"xaxis\": {\r\n    \"buckets\": null,\r\n    \"mode\": \"series\",\r\n    \"name\": null,\r\n    \"show\": false,\r\n    \"values\": [\r\n      \"total\"\r\n    ]\r\n  },\r\n  \"yaxes\": [\r\n    {\r\n      \"format\": \"short\",\r\n      \"label\": null,\r\n      \"logBase\": 1,\r\n      \"max\": null,\r\n      \"min\": null,\r\n      \"show\": true\r\n    },\r\n    {\r\n      \"format\": \"short\",\r\n      \"label\": null,\r\n      \"logBase\": 1,\r\n      \"max\": null,\r\n      \"min\": null,\r\n      \"show\": true\r\n    }\r\n  ]\r\n}"},"comment":{"url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin/issues/comments/305256162","html_url":"https://github.com/grafana-druid-plugin/druidplugin/issues/15#issuecomment-305256162","issue_url":"https://api.github.com/repos/grafana-druid-plugin/druidplugin/issues/15","id":305256162,"user":{"login":"knoguchi","id":127546,"avatar_url":"https://avatars0.githubusercontent.com/u/127546?v=3","gravatar_id":"","url":"https://api.github.com/users/knoguchi","html_url":"https://github.com/knoguchi","followers_url":"https://api.github.com/users/knoguchi/followers","following_url":"https://api.github.com/users/knoguchi/following{/other_user}","gists_url":"https://api.github.com/users/knoguchi/gists{/gist_id}","starred_url":"https://api.github.com/users/knoguchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/knoguchi/subscriptions","organizations_url":"https://api.github.com/users/knoguchi/orgs","repos_url":"https://api.github.com/users/knoguchi/repos","events_url":"https://api.github.com/users/knoguchi/events{/privacy}","received_events_url":"https://api.github.com/users/knoguchi/received_events","type":"User","site_admin":false},"created_at":"2017-05-31T17:17:52Z","updated_at":"2017-05-31T17:17:52Z","body":"Here is a quick hack to apply the template variable on groupBy field.\r\n\r\n```\r\ndiff --git a/src/datasource.js b/src/datasource.js\r\nindex a79c8fc..7b7991e 100644\r\n--- a/src/datasource.js\r\n+++ b/src/datasource.js\r\n@@ -115,7 +115,7 @@ function (angular, _, dateMath, moment) {\r\n       var filters = target.filters;\r\n       var aggregators = target.aggregators;\r\n       var postAggregators = target.postAggregators;\r\n-      var groupBy = target.groupBy;\r\n+      var groupBy = _.map(target.groupBy, (e) => { return templateSrv.replace(e) });\r\n       var limitSpec = null;\r\n       var metricNames = getMetricNames(aggregators, postAggregators);\r\n       var intervals = getQueryIntervals(from, to);\r\n```"}}
{"actor":{"display_login":"knoguchi"}}