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

Stackdriver: Template variables in filters using globbing format #15182

Closed
jameshartig opened this issue Feb 1, 2019 · 3 comments
Closed

Stackdriver: Template variables in filters using globbing format #15182

jameshartig opened this issue Feb 1, 2019 · 3 comments

Comments

@jameshartig
Copy link

jameshartig commented Feb 1, 2019

We're running Grafana 5.4.3. I created a variable $device that I want to use to filter all of the graphs on the dashboard by a particular device. I set up the template variable as so:
image

I thought I could then do:
image

But the graph shows no data points. It looks like it's sending the variable with {} around it:

{"from":"1548983617008","to":"1548994417008","queries":[{"refId":"A","intervalMs":10000,"datasourceId":3,"metricType":"compute.googleapis.com/instance/disk/throttled_write_ops_count","primaryAggregation":"REDUCE_MEAN","perSeriesAligner":"ALIGN_DELTA","alignmentPeriod":"stackdriver-auto","groupBys":["metric.label.device_name"],"view":"FULL","filters":["metric.label.device_name","=~","{william-mongo-sessions-ssd}"],"aliasBy":"{{ metric.label.device_name }}","type":"timeSeriesQuery"}]}

Specifically: ["metric.label.device_name","=~","{william-mongo-sessions-ssd}"] when I believe it should just have been ["metric.label.device_name","=~","william-mongo-sessions-ssd"]

Finally, are variables supported in the template queries? We typically have a hierarchy as so:
image
Where selecting zone will filter instances and devices. Selecting an instance will filter devices. I don't see a way in the template query page to add a filter.

@torkelo
Copy link
Member

torkelo commented Feb 1, 2019

Looks like the format is not specified in the replace (interpolation) call:
https://github.com/grafana/grafana/blob/master/public/app/plugins/datasource/stackdriver/datasource.ts#L43

There is a 3rd optional argument to replace that controls how multi-valued variables will be interpolated. Looks like for filters it should be regex and not the default glob syntax.

@daniellee
Copy link
Contributor

It should be possible to chain variables, they should appear in the dropdown list. Here is an example:

image

image

@daniellee
Copy link
Contributor

Also, it is possible to change how multi variables are concatenated. Docs here. In your case it would be:

${device:regex}

But fix coming up that changes the default to be regex for filters.

daniellee added a commit that referenced this issue Feb 5, 2019
For the filter expression, a better default is to
interpolate multi variables as a regex rather than
the default globbing pattern.

Also, uses the real TemplateSrv class rather than
stubbing it in the tests.
@daniellee daniellee added this to the 6.0-beta2 milestone Feb 5, 2019
daniellee added a commit that referenced this issue Feb 5, 2019
Changes default interpolation for Stackdriver filter to be regex. Fixes #15182
@daniellee daniellee changed the title Stackdriver: Template variables in filters not working Stackdriver: Template variables in filters using globbing format Feb 5, 2019
daniellee added a commit that referenced this issue Feb 5, 2019
ryantxu added a commit to ryantxu/grafana that referenced this issue Feb 5, 2019
* grafana/master: (23 commits)
  changelog: adds note for grafana#15182
  stackdriver: fixes grafana#15182
  Closing timepicker when clicking outside the picker
  Optimized so we only do checks when dropdown is opened
  stackdriver: add some more typings
  Fixed so that we close angular TimePicker when user clicks outside the dropdown
  Fixes grafana#15223 by handling onPaste event because of bug in Slate
  docs: fixes grafana#14940
  added missing typing to explore props
  improve the stackdriver logo
  Fixed so onBlur event trigger an QueryChange and QueryExecute if values differ
  Renamed initialQueries to queries
  Missed to save
  Fixed bug with removing a QueryRow thats not part of nextQueries
  Replaced intialQueris with queryKeys
  Reverted redux-logger
  Added more typings
  Removed modifiedQueries from state
  Merge with master
  Refactor of action, actionTypes and reducer
  ...
ryantxu added a commit to ryantxu/grafana that referenced this issue Feb 6, 2019
* grafana/master: (977 commits)
  changelog: add notes about closing grafana#15265
  Added ServerlessDatabaseCapacity metric to list of AWS RDS metrics.
  changelog: add notes about closing grafana#8207
  cloudwatch: Add tests for resource_arn template query
  cloudwatch: Add resource_arns template query function Implements feature request grafana#8207
  update to aws-sdk-go v1.16.15
  Updated add panel related flows
  changelog: adds note for grafana#15182
  stackdriver: fixes grafana#15182
  Closing timepicker when clicking outside the picker
  Optimized so we only do checks when dropdown is opened
  stackdriver: add some more typings
  Fixed so that we close angular TimePicker when user clicks outside the dropdown
  Fixes grafana#15223 by handling onPaste event because of bug in Slate
  minor layout change, simple render test
  docs: fixes grafana#14940
  added missing typing to explore props
  improve the stackdriver logo
  Fixed so onBlur event trigger an QueryChange and QueryExecute if values differ
  Renamed initialQueries to queries
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants