Dashboard JSON: How to declare a global `"datasource"`

  • What Grafana version and what operating system are you using?

    Latest as of posting

  • What are you trying to achieve?

    I am writing the json model for my dashboard mostly manually (for importing / provisioning). This works great. Currently I am repeating the "datasource": {…} block for each panel. This is fine, if panels have different datasources. But if all of my many panels have the same, it would be nice, if I would only need to write it once (DRY).

  • What did you expect to happen?

    A way to declare it globally (maybe as a “default”. Panels not setting it would inherit that)

  • Can you copy/paste the configuration(s) that you are having problems with?

    What should I paste here?

  • Did you follow any online instructions? If so, what is the URL?

    Did not find anything telling me how to declare that global default.

datasources are per panel so that would break the data model

Can you please elaborate on what would break if a dashboard json for importing has a “default” datasource. So that panel without one would use that?

Use dashboard variable. See for example AWS EC2 | Grafana Labs