Required fields in MySQL Datasource Panel and Dashboard JSON objects

Hi All,

I am trying to automate dashboard creation using the HTTP API provided for the same. There seems to be no documentation on the JSON object fields for Panels in a dashboard. I’ve been trying to view the JSON for a panel and the structure seems to be quite extensive.

  1. Is there documentation on Panel structure provided on the site that I have possibly missed out on?
  2. Which fields in a Panel JSON structure are absolutely essential to be provided in HTTP POST request? Additionally, which fields in Dashboard JSON structure are essential as well?
  1. https://grafana.com/docs/grafana/latest/reference/dashboard/#dashboard-json

  2. For the Dashboard: if you don’t have an id, Grafana will create one for you. The id field needs to be null, as it might produce an error otherwise.

Minimal example using curl

    curl --request POST --url 'http://admin:admin@localhost:3000/api/dashboards/db?orgId=1' --header 'content-type: application/json' --data '{    "dashboard" : {
        "id" : null,
        "title" : "test dashboard",
        "timezone": "browser",
        "version": 34
    },
    "overwrite": false
}'

Se also the example request here https://grafana.com/docs/grafana/latest/http_api/dashboard/

1 Like