Set variable to global variable if defined

:wave: all,

We are not using scripted dashboards (yet) and we want to have a default value for a variable to use in queries. So this variable is set to say public if the global ${__user.login} is not defined. This is the case in anonymous login. Otherwise it is set to that global.

Is there perhaps any other way we might implement this to have queries based on the logged in user or a default value if anonymous?

Appreciate any tips.
Many thanks
Eric
humanalyse.com

Hi @allomorphy,

Interesting question. Can you provide some extra info about what you’re trying to achieve and why? And what Grafana version are you using?

Thank you @mattabrams

We are always on bleeding edge version.
I wanted to display results for a not logged in user.
Now all our queries are based on that global ${__user.login} .

We solved it by writing data without the relevant tag defined so when influxdb calls against the undefined global var it returns all those measurements which are undefined for that tag.
Works perfectly as you see here:
https://humanalyse.com/d/qiAZX2kGa/meterbolic-org-standard-dashboard?orgId=3&from=1619853960725&to=1619869165351&kiosk

Thanks for your interest and best wishes
Eric

We are building the future of Grafana in Health and Health in populations.Come and join in 🤗

that’s a beautiful dashboard! Do you mind if I share it with some people in the company? I’m making a list of great dashboards from the community

Thank you, that is very kind :blush: and that is why we shared it @mattabrams, so please feel free and we hope that it will encourage others to join us!
Our visualisations are about to get much better, we are hoping to collaborate with the core team to sweat and increase the Grafana capabilities to make it the default solution for Health.

Reference: How Grafana is helping the DIFFERENCE Foundation visualize medical data in their fight against a global pandemic | Grafana Labs