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

Query tags from InfluxDB with respect of timeFilter for Grafana variables templating #27

Closed
oijkn opened this issue Jan 17, 2021 · 2 comments

Comments

@oijkn
Copy link

oijkn commented Jan 17, 2021

Hi,

You use InfluxDB tags as variables in Grafana and I would like to limit tags by time range selected there.

Using $timeFrame is supported for select InfluxDB queries but tags are returned by "SHOW TAGS" which doesn't support $timeFrame: influxdata/influxdb#5668

For example in the parameters of this variable I have old names of VMs that appear when they no longer exist following the selection of the time range
image

I tested the following query and it seems to work well (maybe to be optimized?) :

SHOW TAG VALUES FROM vsphere_vm_cpu WITH KEY=vmname WHERE "vcenter" =~ /$vcenter/ to SELECT DISTINCT("vmname") FROM (SELECT * FROM "vsphere_vm_cpu" WHERE $timeFilter AND "vcenter" =~ /$vcenter/)

The workaround appears to involve subqueries, and retrieves every point in the timeFilter -- grafana handles the de-dupe

SELECT "tag" FROM (SELECT "field", "tag" FROM "table" WHERE $timeFilter)

Could you fix this bug in all dashboards, please?

Thank you in advance for your help.

@jorgedlcruz
Copy link
Owner

Hello
Can you imagine that I've fixed this six days ago on the grafana.com dashboards but never hit the commit button here? Look at the revision on monday the 11th:
https://grafana.com/grafana/dashboards/8159/revisions

Now all the dashboards are here as well, let me know if that is what you are looking for, looks similar but not quite the same.

@oijkn
Copy link
Author

oijkn commented Jan 18, 2021

@jorgedlcruz great thank you for this update, so far so good :)

@oijkn oijkn closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants