grafonnet icon indicating copy to clipboard operation
grafonnet copied to clipboard

Automating Grafonnet Dashboards: jsonnet JSON Output Not Compatible with Grafana HTTP API

Open amitoj opened this issue 1 year ago • 2 comments

I'm using the Grafonnet library to generate dashboard JSONs, but while the output works when manually added to Grafana, I want to automate the process for continuous development and validation. When I attempt to create the dashboard via the Grafana HTTP API, it rejects the JSON generated by Grafonnet because the API requires a wrapped format.

The Grafonnet JSON output looks like this (using small format without panels for brevity) :

{ 
    "id": null,
    "uid": null,
    "title": "Production Overview",
    "tags": [ "templated" ],
    "timezone": "browser",
    "schemaVersion": 16,
    "refresh": "25s"
}

But the HTTP API expects:

{
  "dashboard": {
    "id": null,
    "uid": null,
    "title": "Production Overview",
    "tags": [ "templated" ],
    "timezone": "browser",
    "schemaVersion": 16,
    "refresh": "25s"
  },
  "folderUid": "l3KqBxCMz",
  "message": "Made changes to xyz",
  "overwrite": false
}

There seems to be no Grafonnet function to wrap the dashboard JSON with the necessary metadata (e.g., folderUid, message, overwrite).

How are others automating this process for CI/CD workflows with Grafonnet? Am I missing a step or workaround? Any insights or recommended solutions would be appreciated.

amitoj avatar Sep 27 '24 13:09 amitoj