Dashboard API

If you are running Grafana Enterprise, for some endpoints you’ll need to have specific permissions. Refer to Role-based access control permissions for more information.

Identifier (id) vs unique identifier (uid)

The identifier (id) of a dashboard is an auto-incrementing numeric value and is only unique per Grafana install.

The unique identifier (uid) of a dashboard can be used for uniquely identify a dashboard between multiple Grafana installs. It’s automatically generated if not provided when creating a dashboard. The uid allows having consistent URLs for accessing dashboards and when syncing dashboards between multiple Grafana installs, see dashboard provisioning for more information. This means that changing the title of a dashboard will not break any bookmarked links to that dashboard.

The uid can have a maximum length of 40 characters.

Create / Update dashboard

POST /api/dashboards/db

Creates a new dashboard or updates an existing dashboard. When updating existing dashboards, if you do not define the folderId or the folderUid property, then the dashboard(s) are moved to the General folder. (You need to define only one property, not both).

Required permissions

See note in the introduction for an explanation.

ActionScope
dashboards:createfolders:*

Example Request for new dashboard:

  1. POST /api/dashboards/db HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
  5. {
  6. "dashboard": {
  7. "id": null,
  8. "uid": null,
  9. "title": "Production Overview",
  10. "tags": [ "templated" ],
  11. "timezone": "browser",
  12. "schemaVersion": 16,
  13. "version": 0,
  14. "refresh": "25s"
  15. },
  16. "folderId": 0,
  17. "folderUid": "l3KqBxCMz",
  18. "message": "Made changes to xyz",
  19. "overwrite": false
  20. }

JSON Body schema:

  • dashboard – The complete dashboard model, id = null to create a new dashboard.
  • dashboard.id – id = null to create a new dashboard.
  • dashboard.uid – Optional unique identifier when creating a dashboard. uid = null will generate a new uid.
  • folderId – The id of the folder to save the dashboard in.
  • folderUid – The UID of the folder to save the dashboard in. Overrides the folderId.
  • overwrite – Set to true if you want to overwrite existing dashboard with newer version, same dashboard title in folder or same dashboard uid.
  • message - Set a commit message for the version history.
  • refresh - Set the dashboard refresh interval. If this is lower than the minimum refresh interval, then Grafana will ignore it and will enforce the minimum refresh interval.

For adding or updating an alert rule for a dashboard panel the user should declare a dashboard.panels.alert block.

Example Request for updating dashboard alert rule:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 78
  4. {
  5. "dashboard": {
  6. "id": 104,
  7. "panels": [
  8. {
  9. "alert": {
  10. "alertRuleTags": {},
  11. "conditions": [
  12. {
  13. "evaluator": {
  14. "params": [
  15. 25
  16. ],
  17. "type": "gt"
  18. },
  19. "operator": {
  20. "type": "and"
  21. },
  22. "query": {
  23. "params": [
  24. "A",
  25. "5m",
  26. "now"
  27. ]
  28. },
  29. "reducer": {
  30. "params": [],
  31. "type": "avg"
  32. },
  33. "type": "query"
  34. }
  35. ],
  36. "executionErrorState": "alerting",
  37. "for": "5m",
  38. "frequency": "1m",
  39. "handler": 1,
  40. "name": "Panel Title alert",
  41. "noDataState": "no_data",
  42. "notifications": []
  43. },
  44. "aliasColors": {},
  45. "bars": false,
  46. "dashLength": 10,
  47. "dashes": false,
  48. "datasource": null,
  49. "fieldConfig": {
  50. "defaults": {
  51. "custom": {}
  52. },
  53. "overrides": []
  54. },
  55. "fill": 1,
  56. "fillGradient": 0,
  57. "gridPos": {
  58. "h": 9,
  59. "w": 12,
  60. "x": 0,
  61. "y": 0
  62. },
  63. "hiddenSeries": false,
  64. "id": 2,
  65. "legend": {
  66. "avg": false,
  67. "current": false,
  68. "max": false,
  69. "min": false,
  70. "show": true,
  71. "total": false,
  72. "values": false
  73. },
  74. "lines": true,
  75. "linewidth": 1,
  76. "nullPointMode": "null",
  77. "options": {
  78. "dataLinks": []
  79. },
  80. "percentage": false,
  81. "pointradius": 2,
  82. "points": false,
  83. "renderer": "flot",
  84. "seriesOverrides": [],
  85. "spaceLength": 10,
  86. "stack": false,
  87. "steppedLine": false,
  88. "targets": [
  89. {
  90. "refId": "A",
  91. "scenarioId": "random_walk"
  92. }
  93. ],
  94. "thresholds": [
  95. {
  96. "colorMode": "critical",
  97. "fill": true,
  98. "line": true,
  99. "op": "gt",
  100. "value": 50
  101. }
  102. ],
  103. "timeFrom": null,
  104. "timeRegions": [],
  105. "timeShift": null,
  106. "title": "Panel Title",
  107. "tooltip": {
  108. "shared": true,
  109. "sort": 0,
  110. "value_type": "individual"
  111. },
  112. "type": "graph",
  113. "xaxis": {
  114. "buckets": null,
  115. "mode": "time",
  116. "name": null,
  117. "show": true,
  118. "values": []
  119. },
  120. "yaxes": [
  121. {
  122. "format": "short",
  123. "label": null,
  124. "logBase": 1,
  125. "max": null,
  126. "min": null,
  127. "show": true
  128. },
  129. {
  130. "format": "short",
  131. "label": null,
  132. "logBase": 1,
  133. "max": null,
  134. "min": null,
  135. "show": true
  136. }
  137. ],
  138. "yaxis": {
  139. "align": false,
  140. "alignLevel": null
  141. }
  142. }
  143. ],
  144. "title": "Update alert rule via API",
  145. "uid": "dHEquNzGz",
  146. "version": 1
  147. }
  148. }

Example Response:

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 78
  4. {
  5. "id": 1,
  6. "uid": "cIBgcSjkk",
  7. "url": "/d/cIBgcSjkk/production-overview",
  8. "status": "success",
  9. "version": 1,
  10. "slug": "production-overview" //deprecated in Grafana v5.0
  11. }

Status Codes:

  • 200 – Created
  • 400 – Errors (invalid json, missing or invalid fields, etc)
  • 401 – Unauthorized
  • 403 – Access denied
  • 412 – Precondition failed

The 412 status code is used for explaining that you cannot create the dashboard and why. There can be different reasons for this:

  • The dashboard has been changed by someone else, status=version-mismatch
  • A dashboard with the same name in the folder already exists, status=name-exists
  • A dashboard with the same uid already exists, status=name-exists
  • The dashboard belongs to plugin <plugin title>, status=plugin-dashboard

The response body will have the following properties:

  1. HTTP/1.1 412 Precondition Failed
  2. Content-Type: application/json; charset=UTF-8
  3. Content-Length: 97
  4. {
  5. "message": "The dashboard has been changed by someone else",
  6. "status": "version-mismatch"
  7. }

In case of title already exists the status property will be name-exists.

Get dashboard by uid

GET /api/dashboards/uid/:uid

Will return the dashboard given the dashboard unique identifier (uid). Information about the unique identifier of a folder containing the requested dashboard might be found in the metadata.

Required permissions

See note in the introduction for an explanation.

ActionScope
dashboards:readdashboards:*

Example Request:

  1. GET /api/dashboards/uid/cIBgcSjkk HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "dashboard": {
  5. "id": 1,
  6. "uid": "cIBgcSjkk",
  7. "title": "Production Overview",
  8. "tags": [ "templated" ],
  9. "timezone": "browser",
  10. "schemaVersion": 16,
  11. "version": 0
  12. },
  13. "meta": {
  14. "isStarred": false,
  15. "url": "/d/cIBgcSjkk/production-overview",
  16. "folderId": 2,
  17. "folderUid": "l3KqBxCMz",
  18. "slug": "production-overview" //deprecated in Grafana v5.0
  19. }
  20. }

Status Codes:

  • 200 – Found
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found

Delete dashboard by uid

DELETE /api/dashboards/uid/:uid

Will delete the dashboard given the specified unique identifier (uid).

Required permissions

See note in the introduction for an explanation.

ActionScope
dashboards:deletedashboards:
folders:

Example Request:

  1. DELETE /api/dashboards/uid/cIBgcSjkk HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "title": "Production Overview",
  5. "message": "Dashboard Production Overview deleted",
  6. "id": 2
  7. }

Status Codes:

  • 200 – Deleted
  • 401 – Unauthorized
  • 403 – Access denied
  • 404 – Not found

Gets the home dashboard

GET /api/dashboards/home

Will return the home dashboard.

Example Request:

  1. GET /api/dashboards/home HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. {
  4. "dashboard": {
  5. "editable":false,
  6. "nav":[
  7. {
  8. "enable":false,
  9. "type":"timepicker"
  10. }
  11. ],
  12. "style":"dark",
  13. "tags":[],
  14. "templating":{
  15. "list":[
  16. ]
  17. },
  18. "time":{
  19. },
  20. "timezone":"browser",
  21. "title":"Home",
  22. "version":5
  23. },
  24. "meta": {
  25. "isHome":true,
  26. "canSave":false,
  27. "canEdit":false,
  28. "canStar":false,
  29. "url":"",
  30. "expires":"0001-01-01T00:00:00Z",
  31. "created":"0001-01-01T00:00:00Z"
  32. }
  33. }

Tags for Dashboard

GET /api/dashboards/tags

Get all tags of dashboards

Example Request:

  1. GET /api/dashboards/tags HTTP/1.1
  2. Accept: application/json
  3. Content-Type: application/json
  4. Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

Example Response:

  1. HTTP/1.1 200
  2. Content-Type: application/json
  3. [
  4. {
  5. "term":"tag1",
  6. "count":1
  7. },
  8. {
  9. "term":"tag2",
  10. "count":4
  11. }
  12. ]

See Folder/Dashboard Search API.