Dashboard JSON schema

Where can I find JSON schema for dashboards?
Information on https://grafana.com/docs/reference/dashboard/#dashboard-json is not complete and I could not find one in the sourcecode on GitHub.

Can someone please guide me?

Hi vihangvk,

I think there is no documentation about it, the best thing you can do is create dashboards from the UI and export the JSON.

Thanks Daniel.

Exported JSON has many fields with default values which could be dropped if we have some way to validate it. Also JSON is not easy to edit, so I was planning to use YAML. If there is some official schema available it would be easy to validate those files against it.

I was here looking for the same thing. There seems to be no single source of truth about what fields are in which version.

Yeeikes. Surely there must be a model parser somewhere in the grafana source? Perhaps we could derive a proper schema from the grafana source?

Hmmm progress: grafana/packages/grafana-schema/src/veneer/dashboard.types.ts at main · grafana/grafana · GitHub

We could pump @grafana/schema through a TS → JSONSchema generator. ts-json-schema-generator - npm

However, really the TS types are even better for my use case!

Good luck out there.

1 Like

what’s the end goal of this noble effort? use case yadi yada

Dashboard generation, validation, etc. Currently, DB gen is thru WYSIWYG UI only. Our team has a handful of variations of dashboards where we’ve decided we’re best served via generation rather than manual editing. We want to:

  • generate dashboards with minor variations
  • generate facets of panels (as general faceting is not really supported in grafana ATM)
  • bulk update common panel properties for dashboards via source control’d config
  • …etc etc
1 Like