Too many Dashboard Versions. Config versions_to_keep not working as expected

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”: [
“time_options”: [
“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:


Number dashboard versions to keep (per dashboard). Default: 20, Minimum: 1.


  1. How to make sure versions_to_keep works?
  2. How to make sure a dashboard overwrites the same UID one without creating a new version of it ?
  3. Should we change overwrite to false? In that case would we have to query the current version of the dashboard?
  4. Any other tip?