2016-10-21 04:01:34 -05:00
+++
title = "JSON Model"
keywords = ["grafana", "dashboard", "documentation", "json", "model"]
type = "docs"
[menu.docs]
name = "JSON Model"
parent = "dashboard_features"
weight = 100
+++
2015-11-02 01:17:23 -06:00
# Dashboard JSON
2018-02-08 02:55:12 -06:00
A dashboard in Grafana is represented by a JSON object, which stores metadata of its dashboard. Dashboard metadata includes dashboard properties, metadata from panels, template variables, panel queries, etc.
2015-11-02 01:17:23 -06:00
2015-11-02 01:53:24 -06:00
To view the JSON of a dashboard, follow the steps mentioned below:
2015-11-02 01:17:23 -06:00
2015-11-02 01:53:24 -06:00
1. Go to a dashboard
2. Click on `Manage dashboard` menu on the top navigation bar
3. Select `View JSON` from the dropdown menu
2015-11-02 01:17:23 -06:00
2015-11-02 02:21:59 -06:00
## JSON fields
2015-11-02 01:17:23 -06:00
2015-11-02 01:53:24 -06:00
When a user creates a new dashboard, a new dashboard JSON object is initialized with the following fields:
2015-11-02 02:21:59 -06:00
> Note: In the following JSON, id is shown as null which is the default value assigned to it until a dashboard is saved. Once a dashboard is saved, an integer value is assigned to the `id` field.
2015-11-02 01:17:23 -06:00
2017-10-05 12:01:03 -05:00
```json
2015-11-02 01:17:23 -06:00
{
"id": null,
2018-02-08 02:55:12 -06:00
"uid": "cLV5GDCkz",
2015-11-02 01:17:23 -06:00
"title": "New dashboard",
"tags": [],
"style": "dark",
"timezone": "browser",
2015-11-02 01:53:24 -06:00
"editable": true,
2015-11-02 01:17:23 -06:00
"hideControls": false,
2016-12-14 07:33:33 -06:00
"graphTooltip": 1,
2018-02-08 02:55:12 -06:00
"panels": [],
2015-11-02 01:17:23 -06:00
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
2015-11-02 02:21:59 -06:00
"time_options": [],
"refresh_intervals": []
2015-11-02 01:17:23 -06:00
},
"templating": {
"list": []
},
"annotations": {
"list": []
},
2018-02-21 03:47:14 -06:00
"schemaVersion": 16,
2015-11-02 01:17:23 -06:00
"version": 0,
"links": []
}
```
2015-11-02 01:53:24 -06:00
Each field in the dashboard JSON is explained below with its usage:
| Name | Usage |
| ---- | ----- |
2018-02-08 02:55:12 -06:00
| **id** | unique numeric identifier for the dashboard. (generated by the db) |
2018-02-21 03:47:14 -06:00
| **uid** | unique dashboard identifier that can be generated by anyone. string (8-40) |
2015-11-02 01:53:24 -06:00
| **title** | current title of dashboard |
2015-11-02 02:21:59 -06:00
| **tags** | tags associated with dashboard, an array of strings |
| **style** | theme of dashboard, i.e. `dark` or `light` |
| **timezone** | timezone of dashboard, i.e. `utc` or `browser` |
2015-11-02 01:53:24 -06:00
| **editable** | whether a dashboard is editable or not |
2017-06-04 07:23:52 -05:00
| **graphTooltip** | 0 for no shared crosshair or tooltip (default), 1 for shared crosshair, 2 for shared crosshair AND shared tooltip |
2015-11-02 02:21:59 -06:00
| **time** | time range for dashboard, i.e. last 6 hours, last 7 days, etc |
2017-02-07 00:48:01 -06:00
| **timepicker** | timepicker metadata, see [timepicker section ](#timepicker ) for details |
| **templating** | templating metadata, see [templating section ](#templating ) for details |
| **annotations** | annotations metadata, see [annotations section ](#annotations ) for details |
2017-12-29 02:45:07 -06:00
| **schemaVersion** | version of the JSON schema (integer), incremented each time a Grafana update brings changes to the said schema |
| **version** | version of the dashboard (integer), incremented each time the dashboard is updated |
2018-02-21 03:47:14 -06:00
| **panels** | panels array, see below for detail. |
2015-11-02 02:21:59 -06:00
2018-02-21 03:47:14 -06:00
## Panels
2015-11-02 02:21:59 -06:00
2018-02-21 03:47:14 -06:00
Panels are the building blocks a dashboard. It consists of datasource queries, type of graphs, aliases, etc. Panel JSON consists of an array of JSON objects, each representing a different panel. Most of the fields are common for all panels but some fields depends on the panel type. Following is an example of panel JSON of a text panel.
2015-11-02 12:15:40 -06:00
2017-02-07 00:48:01 -06:00
```json
2015-11-02 12:15:40 -06:00
"panels": [
2018-02-21 03:47:14 -06:00
{
"type": "text",
"title": "Panel Title",
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 9
2015-11-02 02:21:59 -06:00
},
2018-02-21 03:47:14 -06:00
"id": 4,
"mode": "markdown",
"content": "# title"
}
2015-11-02 12:15:40 -06:00
```
2018-02-21 03:47:14 -06:00
### Panel size & position
2015-11-02 12:15:40 -06:00
2018-02-21 03:47:14 -06:00
The gridPos property describes the panel size and position in grid coordinates.
2015-11-02 12:15:40 -06:00
2018-02-21 03:47:14 -06:00
- `w` 1-24 (the width of the dashboard is divided into 24 columns)
- `h` In grid height units, each represents 30 pixels.
- `x` The x position, in same unit as `w` .
- `y` The y position, in same unit as `h` .
2015-11-02 12:15:40 -06:00
2018-02-21 03:47:14 -06:00
The grid has a negative gravity that moves panels up if there i empty space above a panel.
2015-11-02 02:21:59 -06:00
### timepicker
2017-02-07 00:48:01 -06:00
```json
2015-11-02 12:15:40 -06:00
"timepicker": {
"collapse": false,
"enable": true,
"notice": false,
"now": true,
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"status": "Stable",
"time_options": [
"5m",
"15m",
"1h",
"3h",
"6h",
"12h",
"24h",
"2d",
"3d",
"4d",
"7d",
"30d"
],
"type": "timepicker"
}
```
Usage of the fields is explained below:
| Name | Usage |
| ---- | ----- |
| **collapse** | whether timepicker is collapsed or not |
| **enable** | whether timepicker is enabled or not |
| **notice** | TODO |
| **now** | TODO |
| **refresh_intervals** | TODO |
| **status** | TODO |
| **time_options** | TODO |
| **type** | TODO |
2015-11-02 02:21:59 -06:00
### templating
2015-11-02 12:15:40 -06:00
`templating` fields contains array of template variables with their saved values along with some other metadata, for example:
2017-02-07 00:48:01 -06:00
```json
2015-11-02 12:15:40 -06:00
"templating": {
"enable": true,
"list": [
{
"allFormat": "wildcard",
"current": {
"tags": [],
"text": "prod",
"value": "prod"
},
"datasource": null,
"includeAll": true,
"name": "env",
"options": [
{
"selected": false,
"text": "All",
"value": "*"
},
{
"selected": false,
"text": "stage",
"value": "stage"
},
{
"selected": false,
"text": "test",
"value": "test"
}
],
"query": "tag_values(cpu.utilization.average,env)",
"refresh": false,
2015-12-01 02:01:44 -06:00
"refresh": false,
2015-11-02 12:15:40 -06:00
"type": "query"
},
{
"allFormat": "wildcard",
"current": {
"text": "apache",
"value": "apache"
},
"datasource": null,
"includeAll": false,
"multi": false,
"multiFormat": "glob",
"name": "app",
"options": [
{
"selected": true,
"text": "tomcat",
"value": "tomcat"
},
{
"selected": false,
"text": "cassandra",
"value": "cassandra"
}
],
"query": "tag_values(cpu.utilization.average,app)",
2015-12-01 02:01:44 -06:00
"refresh": false,
2015-11-02 12:15:40 -06:00
"regex": "",
"type": "query"
}
]
}
```
Usage of the above mentioned fields in the templating section is explained below:
| Name | Usage |
| ---- | ----- |
| **enable** | whether templating is enabled or not |
| **list** | an array of objects representing, each representing one template variable |
| **allFormat** | format to use while fetching all values from datasource, eg: `wildcard` , `glob` , `regex` , `pipe` , etc. |
| **current** | shows current selected variable text/value on the dashboard |
| **datasource** | shows datasource for the variables |
| **includeAll** | whether all value option is available or not |
| **multi** | whether multiple values can be selected or not from variable value list |
| **multiFormat** | format to use while fetching timeseries from datasource |
| **name** | name of variable |
| **options** | array of variable text/value pairs available for selection on dashboard |
| **query** | datasource query used to fetch values for a variable |
2015-12-01 02:01:44 -06:00
| **refresh** | TODO |
2015-11-02 12:15:40 -06:00
| **regex** | TODO |
| **type** | type of variable, i.e. `custom` , `query` or `interval` |