Data Link variable for hostname?

Is there a hostname variable that can be used in Data Links? I’m running other services on the same server so I’d like to have data links point there, and I’d like the links to continue working if the DNS or IP address changes.

You don’t need that. Just use relative URL (e.g. /d/dashboarduid/dashboardname?parameters) instead of absolute URL (e. g. https://hostname/d/dashboarduid/dashboardname?parameters)

1 Like

Thank you. However this doesn’t work because it includes the port number. My Grafana is running on the default port 3000 and my other service is running on a different port, so this isn’t working. When I move from dev to prod I might change Grafana to port 80 so then I guess this would work.

Could you prove that this solution won’t be working when you change the port, please? Don’t guess, try it, pls.

1 Like

@jangaraj, if grafana is on port 3000 and some service is on port 4000, there seem to be no way of creating such link in dashboard to this service without hardcoding the host.
It’s quite problematic if you have multiple environments (dev/stage/prod).
I didn’t find any built-in variable for it and grafana does not support custom global variables by default as well, so it looks like the only way of doing that is either using a plugin for global variables or providing the url from database and setting it as dashboard template variable.

You can still be creative - quick idea:

Build “/redirector/” path, where you will generate proper http redirect (301/302 response code) in your favorite programming language/reverse proxy and use that in your datalink, e.g.: