How to get the Grafana server's hostname in a dashboard?

I’d like to have a button or hyperlink on my dashboard that takes the user to another application running on the same server as Grafana, but I don’t know how to find out the hostname of the Grafana server in my dashboard. Is there, say, a pre-defined template variable that holds the hostname? Or is there some other recognized way to do what I want?

I thought of trying to set up something like a simpleJSON datasource that returns the server information and reading it into a panel, but I’d rather do it the “accepted” way if there is one.

Just use a relative or absolute href url (absolute without protocol and domain name).

Maybe I’m missing something obvious, but this preserves the Grafana port 3000. If I link to, say, /myapp, then the link goes to https://myserver:3000/myapp. The other app is running on a different port number.

BTW, I see all the work you do on this site and want to say thank you.

other app? your question did not mention you where running multiple grafana servers :slight_smile:

I have multiple applications running on the same server. One of those applications is Grafana. I’d like to have a link in my Grafana dashboard to one of those other applications.

Use for example javascript in the browser and read “hostname” (window.location.hostname) from the current Grafana URL and then construct your customized URL of your another app. For example:

var url = "http://" + window.location.hostname + ":8000/"

Thank you.

I was trying to put this as a detail link in my dashboard panel, which wasn’t working. But then I realized that text panels support HTML mode using JavaScript, so I can use window.location as you say, e.g. like this:

<a id='link_to_my_page' href=''>My App</a>
<script>
  document.getElementById('link_to_my_page').setAttribute('href', 'https://' + window.location.hostname + ":8000/myapp");
</script>

I think this will be good enough.

Thanks again, everyone.