HowTo create a generic links to Dashboard with provisioning

  • What Grafana version and what operating system are you using?
    11.4.0 onPrem Windows
  • What are you trying to achieve?

I want to ad links to other Dashobards in different panels.

  • How are you trying to achieve it?

create Links to dashboards

  • What happened?

I don’t find the uid of a dashboard, so I can’t create the links in provvisioning

Hi all,

my problem is, tha the “normal” grafana-links are to complicated for automation.Thy looks like this:

https://play.grafana.org/**d/uptmjHzGk**/data-links-cell-value-datalink?orgId=1

How could I find the part d/uptmjHzGk for my dashboards or how could I replace this with a generic part like https://play.grafana.org/**my-dashboards**/data-links-cell-value-datalink?orgId=1

Thanks and regards
Jürgen

Can you share how you provision a dashboard? You should be able to set the ID yourself (the ones you shown are auto-generated, so they are impossible to predict in datalinks), then you know which dashboard has which ID and can create the datalinks.

My tool creates the empty templartes first with this json:

sJSON_DATA = ‘{’,
’ “annotations”: {‘,
’ “list”: [’,
’ {‘,
’ “builtIn”: 1,’,
’ “datasource”: {‘,
’ “type”: “grafana”,’,
’ “uid”: “-- Grafana --”‘,
’ },’,
’ “enable”: true,‘,
’ “hide”: true,’,
’ “iconColor”: “rgba(0, 211, 255, 1)”,‘,
’ “name”: “Annotations & Alerts”,’,
’ “type”: “dashboard”‘,
’ }’,
’ ]‘,
’ },’,
’ “editable”: true,‘,
’ “fiscalYearStartMonth”: 0,’,
’ “graphTooltip”: 0,‘,
’ “id”: null,',
’ “links”: ,’,
’ “panels”: ,‘,
’ “preload”: false,’,
’ “schemaVersion”: 40,‘,
’ “tags”: [‘sTags’],’,
’ “templating”: {‘,
’ “list”: ’,
’ },‘,
’ “time”: {’,
’ “from”: “now-6h”,‘,
’ “to”: “now”’,
’ },‘,
’ “timepicker”: {’,
’ “refresh_intervals”: [‘,
’ “1m”,’,
’ “5m”,‘,
’ “15m”,’,
’ “30m”,‘,
’ “1h”,’,
’ “2h”,‘,
’ “1d”’,
’ ]‘,
’ },’,
’ “timezone”: “browser”,‘,
’ “title”: “‘sCIName’”,’,
’ “version”: 1,‘,
’ “weekStart”: “”’,
‘}’;

If I understand you correct, I’ve to set the id at creation, then I’ll get the link I need?
Or is there another useful key, whixch I don’t use at the moment?

Thanks a lot.

Can your tool set the JSON to be:

{
...
title: sCIName,
version: 1,
weekStart: "",
uid: "<some random / not random string>"
}

(not valid json but adding the uid field is important).

That’s how you set the uid of the dashboard that is then reflected in the path (e.g. uptmjHzGk from your example). There’s no automatic link addition but with uid set in stone (like in the part of JSON above), you’ll be able to determine the link - the base is always (http|https)://<domain>/d/<uid>.

You’re awsome fast with your answer. Thanks a lot.

That’s it. I’ve tested it with the uid and it works :slight_smile:

Thanks for the hint.

1 Like