We are using the following template to dynamically create/update our Grafana Dashboards.
We use the API POST /api/dashboards/db
The template looks like:
{
“dashboard”: {
“editable”: false,
“gnetId”: null,
“graphTooltip”: 0,
“hideControls”: true,
“id”: null,
“uid” : “<<DASHBOARD_UID>>”,
“tags”: [ “<<FOLDER_NAME>>” ],
“links”: [],
“panels”: [
<>
],
“refresh”: “30s”,
“schemaVersion”: 16,
“style”: “dark”,
“templating”: {
“list”: []
},
“time”: {
“from”: “now-3h”,
“to”: “now”
},
“timepicker”: {
“refresh_intervals”: [
“5s”,
“10s”,
“30s”,
“1m”,
“5m”,
“15m”,
“30m”,
“1h”,
“2h”,
“1d”
],
“time_options”: [
“5m”,
“15m”,
“1h”,
“6h”,
“12h”,
“24h”,
“2d”,
“7d”,
“30d”
]
},
“timezone”: “browser”,
“title”: “<<SERVICE_NAME>>”,
“version”: 115
},
“folderId”: <<FOLDER_ID>>,
“overwrite”: true
}
Every time a dashboard is created, a new version of it is added to the Grafana config database regardless of the max default of 20 versions:
[dashboards]
versions_to_keep
Number dashboard versions to keep (per dashboard). Default: 20, Minimum: 1.
Question:
- How to make sure versions_to_keep works?
- How to make sure a dashboard overwrites the same UID one without creating a new version of it ?
- Should we change overwrite to false? In that case would we have to query the current version of the dashboard?
- Any other tip?