| 
									
										
										
										
											2016-11-24 17:16:24 +08:00
										 |  |  |  | +++ | 
					
						
							|  |  |  |  | title = "Dashboard HTTP API " | 
					
						
							|  |  |  |  | description = "Grafana Dashboard HTTP API" | 
					
						
							|  |  |  |  | keywords = ["grafana", "http", "documentation", "api", "dashboard"] | 
					
						
							|  |  |  |  | aliases = ["/http_api/dashboard/"] | 
					
						
							|  |  |  |  | type = "docs" | 
					
						
							|  |  |  |  | [menu.docs] | 
					
						
							|  |  |  |  | name = "Dashboard" | 
					
						
							|  |  |  |  | parent = "http_api" | 
					
						
							|  |  |  |  | +++ | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | # Dashboard API
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | ## Create / Update dashboard
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | `POST /api/dashboards/db` | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Creates a new dashboard or updates an existing dashboard. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Request for new dashboard**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | POST /api/dashboards/db HTTP/1.1 | 
					
						
							|  |  |  |  | Accept: application/json | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   "dashboard": { | 
					
						
							|  |  |  |  |     "id": null, | 
					
						
							|  |  |  |  |     "title": "Production Overview", | 
					
						
							|  |  |  |  |     "tags": [ "templated" ], | 
					
						
							|  |  |  |  |     "timezone": "browser", | 
					
						
							|  |  |  |  |     "rows": [ | 
					
						
							|  |  |  |  |       { | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     ], | 
					
						
							|  |  |  |  |     "schemaVersion": 6, | 
					
						
							|  |  |  |  |     "version": 0 | 
					
						
							|  |  |  |  |   }, | 
					
						
							|  |  |  |  |   "overwrite": false | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | JSON Body schema: | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | - **dashboard** – The complete dashboard model, id = null to create a new dashboard | 
					
						
							|  |  |  |  | - **overwrite** – Set to true if you want to overwrite existing dashboard with newer version or with same dashboard title. | 
					
						
							| 
									
										
										
										
											2017-07-09 08:00:50 +08:00
										 |  |  |  | - **message** - Set a commit message for the version history. | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Response**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 200 OK | 
					
						
							|  |  |  |  | Content-Type: application/json; charset=UTF-8 | 
					
						
							|  |  |  |  | Content-Length: 78 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |   "slug": "production-overview", | 
					
						
							|  |  |  |  |   "status": "success", | 
					
						
							|  |  |  |  |   "version": 1 | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | Status Codes: | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | - **200** – Created | 
					
						
							|  |  |  |  | - **400** – Errors (invalid json, missing or invalid fields, etc) | 
					
						
							|  |  |  |  | - **401** – Unauthorized | 
					
						
							|  |  |  |  | - **412** – Precondition failed | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | The **412** status code is used when a newer dashboard already exists (newer, its version is greater than the version that was sent). The | 
					
						
							|  |  |  |  | same status code is also used if another dashboard exists with the same title. The response body will look like this: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 412 Precondition Failed | 
					
						
							|  |  |  |  | Content-Type: application/json; charset=UTF-8 | 
					
						
							|  |  |  |  | Content-Length: 97 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |   "message": "The dashboard has been changed by someone else", | 
					
						
							|  |  |  |  |   "status": "version-mismatch" | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | In in case of title already exists the `status` property will be `name-exists`. | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | ## Get dashboard
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | `GET /api/dashboards/db/:slug` | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Will return the dashboard given the dashboard slug. Slug is the url friendly version of the dashboard title. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Request**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | GET /api/dashboards/db/production-overview HTTP/1.1 | 
					
						
							|  |  |  |  | Accept: application/json | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Response**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 200 | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |   "meta": { | 
					
						
							|  |  |  |  |     "isStarred": false, | 
					
						
							|  |  |  |  |     "slug": "production-overview" | 
					
						
							|  |  |  |  |   }, | 
					
						
							|  |  |  |  |   "dashboard": { | 
					
						
							|  |  |  |  |     "id": null, | 
					
						
							|  |  |  |  |     "title": "Production Overview", | 
					
						
							|  |  |  |  |     "tags": [ "templated" ], | 
					
						
							|  |  |  |  |     "timezone": "browser", | 
					
						
							|  |  |  |  |     "rows": [ | 
					
						
							|  |  |  |  |       { | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  |       } | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  |     ], | 
					
						
							|  |  |  |  |     "schemaVersion": 6, | 
					
						
							|  |  |  |  |     "version": 0 | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | ## Delete dashboard
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | `DELETE /api/dashboards/db/:slug` | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | The above will delete the dashboard with the specified slug. The slug is the url friendly (unique) version of the dashboard title. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Request**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | DELETE /api/dashboards/db/test HTTP/1.1 | 
					
						
							|  |  |  |  | Accept: application/json | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Response**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 200 | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-08 14:02:08 +08:00
										 |  |  |  | {"title": "Test"} | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | ## Gets the home dashboard
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | `GET /api/dashboards/home` | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | Will return the home dashboard. | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Request**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | GET /api/dashboards/home HTTP/1.1 | 
					
						
							|  |  |  |  | Accept: application/json | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Response**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 200 | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | { | 
					
						
							|  |  |  |  |   "meta":	{ | 
					
						
							|  |  |  |  |     "isHome":true, | 
					
						
							|  |  |  |  |     "canSave":false, | 
					
						
							|  |  |  |  |     "canEdit":false, | 
					
						
							|  |  |  |  |     "canStar":false, | 
					
						
							|  |  |  |  |     "slug":"", | 
					
						
							|  |  |  |  |     "expires":"0001-01-01T00:00:00Z", | 
					
						
							|  |  |  |  |     "created":"0001-01-01T00:00:00Z" | 
					
						
							|  |  |  |  |   }, | 
					
						
							|  |  |  |  |   "dashboard": { | 
					
						
							|  |  |  |  |     "editable":false, | 
					
						
							|  |  |  |  |     "hideControls":true, | 
					
						
							|  |  |  |  |     "nav":[ | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  |       "enable":false, | 
					
						
							|  |  |  |  |       "type":"timepicker" | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  |     ], | 
					
						
							|  |  |  |  |     "rows": [ | 
					
						
							|  |  |  |  |       { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |       } | 
					
						
							|  |  |  |  |     ], | 
					
						
							|  |  |  |  |     "style":"dark", | 
					
						
							|  |  |  |  |     "tags":[], | 
					
						
							|  |  |  |  |     "templating":{ | 
					
						
							|  |  |  |  |       "list":[ | 
					
						
							|  |  |  |  |       ] | 
					
						
							|  |  |  |  |     }, | 
					
						
							|  |  |  |  |     "time":{ | 
					
						
							|  |  |  |  |     }, | 
					
						
							|  |  |  |  |     "timezone":"browser", | 
					
						
							|  |  |  |  |     "title":"Home", | 
					
						
							|  |  |  |  |     "version":5 | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | ## Tags for Dashboard
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | `GET /api/dashboards/tags` | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-24 13:00:42 +08:00
										 |  |  |  | Get all tags of dashboards | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Request**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | GET /api/dashboards/tags HTTP/1.1 | 
					
						
							|  |  |  |  | Accept: application/json | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Response**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 200 | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | [ | 
					
						
							|  |  |  |  |   { | 
					
						
							|  |  |  |  |     "term":"tag1", | 
					
						
							|  |  |  |  |     "count":1 | 
					
						
							|  |  |  |  |   }, | 
					
						
							|  |  |  |  |   { | 
					
						
							|  |  |  |  |     "term":"tag2", | 
					
						
							|  |  |  |  |     "count":4 | 
					
						
							|  |  |  |  |   } | 
					
						
							|  |  |  |  | ] | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:47:34 +08:00
										 |  |  |  | ## Search Dashboards
 | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | `GET /api/search/` | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-29 22:34:22 +08:00
										 |  |  |  | Query parameters: | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | - **query** – Search Query | 
					
						
							| 
									
										
										
										
											2017-03-30 14:54:32 +08:00
										 |  |  |  | - **tag** – Tag to use | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | - **starred** – Flag indicating if only starred Dashboards should be returned | 
					
						
							|  |  |  |  | - **tagcloud** - Flag indicating if a tagcloud should be returned | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Request**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | ```http | 
					
						
							| 
									
										
										
										
											2017-11-02 14:04:51 +08:00
										 |  |  |  | GET /api/search?query=Production%20Overview&starred=true&tag=prod HTTP/1.1 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | Accept: application/json | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							|  |  |  |  | Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk | 
					
						
							|  |  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | **Example Response**: | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | ```http | 
					
						
							|  |  |  |  | HTTP/1.1 200 | 
					
						
							|  |  |  |  | Content-Type: application/json | 
					
						
							| 
									
										
										
										
											2016-02-03 14:59:22 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  | [ | 
					
						
							|  |  |  |  |   { | 
					
						
							|  |  |  |  |     "id":1, | 
					
						
							|  |  |  |  |     "title":"Production Overview", | 
					
						
							|  |  |  |  |     "uri":"db/production-overview", | 
					
						
							|  |  |  |  |     "type":"dash-db", | 
					
						
							| 
									
										
										
										
											2017-11-02 14:04:51 +08:00
										 |  |  |  |     "tags":[prod], | 
					
						
							|  |  |  |  |     "isStarred":true | 
					
						
							| 
									
										
										
										
											2017-10-06 01:01:03 +08:00
										 |  |  |  |   } | 
					
						
							|  |  |  |  | ] | 
					
						
							| 
									
										
										
										
											2017-11-02 14:04:51 +08:00
										 |  |  |  | ``` |