grafana/docs/sources/dashboards/json-model.md

235 lines
9.4 KiB
Markdown
Raw Normal View History

Squashed commit of the following: commit 4113ed00782590187d19dd2f8cbae683f164142c Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Fri Oct 21 10:47:35 2016 +0200 docs(): minor fix for docs index page commit 45478d120571519462fac905aadeab5954696690 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:28:21 2016 +0200 updated commit c9c1c1d5a462f85e8001a45218f24102583d7aee Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:27:34 2016 +0200 docs(): updated image refs commit 5fa0f27963968d77bbbbb7edd973847ea72135e3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Wed Oct 19 14:33:04 2016 +0200 docs is almost done commit 6b988c90cb08563e2c27212338c2947e69f6fcc3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 20:45:28 2016 +0200 almost done commit 17757c21ed813892ddb1f289f2e52613caf7bcef Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 16:45:48 2016 +0200 making progress on docs commit f06c815991dd81b8893912a6da04a17b80b63fda Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 14:30:55 2016 +0200 progress on new docs commit 5197237426252623de2d8b9cc22ddbbdbb240763 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 13:25:26 2016 +0200 making progress commit 33e2b6b617f16f65878141cf11e54b2817a2ea96 Merge: de385e5 ecb4a99 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 12:17:58 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 10:39:59 2016 +0200 keep urls for now commit de385e56d86b071cf2150ccf9f1aa06ec5187277 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:56:18 2016 +0200 more progress commit 8469ebc239ab2316cbbc01862e5026737f272f00 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:08:06 2016 +0200 progress on new docs commit e755f656b12534cfcb23bad11f1fa696e43f7428 Merge: 4644a35 35cce3b Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:27 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit 4644a35102555204787e91041b50dcbfe0f7a213 Merge: 25c4bef 977cdd5 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:11 2016 +0200 Merge branch 'master' of github.com:grafana/grafana into new-docs commit 35cce3bef802fac020a53693b02c112a91a096fc Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 17 09:31:17 2016 +0200 progress on #6170 commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Sun Oct 16 15:05:30 2016 +0200 fix for osx commit 6c6b52f975630be87da23dd51beafaecb820cec2 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 16 12:56:39 2016 +0200 progress on new docs commit 6a09633981ab26191d5542dbe3a788846ac6b73d Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 15 11:39:49 2016 +0200 progress on new docs commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5 Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 10 09:25:12 2016 +0200 making progress on new docs site commit 50392ce98edfa201977716e92e4a86f9d48ae386 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 9 20:02:28 2016 +0200 feat(new docs): progress on new docs site commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686 Author: Torkel Ödegaard <torkel@grafana.org> Date: Fri Oct 7 07:52:11 2016 +0200 new docs site experiment commit 704adc98664665b3624087ab38ce29fc9da005f1 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 1 20:46:53 2016 +0200 new docs poc
2016-10-21 04:01:34 -05:00
+++
title = "JSON model"
Squashed commit of the following: commit 4113ed00782590187d19dd2f8cbae683f164142c Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Fri Oct 21 10:47:35 2016 +0200 docs(): minor fix for docs index page commit 45478d120571519462fac905aadeab5954696690 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:28:21 2016 +0200 updated commit c9c1c1d5a462f85e8001a45218f24102583d7aee Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:27:34 2016 +0200 docs(): updated image refs commit 5fa0f27963968d77bbbbb7edd973847ea72135e3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Wed Oct 19 14:33:04 2016 +0200 docs is almost done commit 6b988c90cb08563e2c27212338c2947e69f6fcc3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 20:45:28 2016 +0200 almost done commit 17757c21ed813892ddb1f289f2e52613caf7bcef Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 16:45:48 2016 +0200 making progress on docs commit f06c815991dd81b8893912a6da04a17b80b63fda Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 14:30:55 2016 +0200 progress on new docs commit 5197237426252623de2d8b9cc22ddbbdbb240763 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 13:25:26 2016 +0200 making progress commit 33e2b6b617f16f65878141cf11e54b2817a2ea96 Merge: de385e5 ecb4a99 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 12:17:58 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 10:39:59 2016 +0200 keep urls for now commit de385e56d86b071cf2150ccf9f1aa06ec5187277 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:56:18 2016 +0200 more progress commit 8469ebc239ab2316cbbc01862e5026737f272f00 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:08:06 2016 +0200 progress on new docs commit e755f656b12534cfcb23bad11f1fa696e43f7428 Merge: 4644a35 35cce3b Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:27 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit 4644a35102555204787e91041b50dcbfe0f7a213 Merge: 25c4bef 977cdd5 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:11 2016 +0200 Merge branch 'master' of github.com:grafana/grafana into new-docs commit 35cce3bef802fac020a53693b02c112a91a096fc Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 17 09:31:17 2016 +0200 progress on #6170 commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Sun Oct 16 15:05:30 2016 +0200 fix for osx commit 6c6b52f975630be87da23dd51beafaecb820cec2 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 16 12:56:39 2016 +0200 progress on new docs commit 6a09633981ab26191d5542dbe3a788846ac6b73d Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 15 11:39:49 2016 +0200 progress on new docs commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5 Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 10 09:25:12 2016 +0200 making progress on new docs site commit 50392ce98edfa201977716e92e4a86f9d48ae386 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 9 20:02:28 2016 +0200 feat(new docs): progress on new docs site commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686 Author: Torkel Ödegaard <torkel@grafana.org> Date: Fri Oct 7 07:52:11 2016 +0200 new docs site experiment commit 704adc98664665b3624087ab38ce29fc9da005f1 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 1 20:46:53 2016 +0200 new docs poc
2016-10-21 04:01:34 -05:00
keywords = ["grafana", "dashboard", "documentation", "json", "model"]
aliases = ["/docs/grafana/latest/reference/dashboard/"]
weight = 1200
Squashed commit of the following: commit 4113ed00782590187d19dd2f8cbae683f164142c Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Fri Oct 21 10:47:35 2016 +0200 docs(): minor fix for docs index page commit 45478d120571519462fac905aadeab5954696690 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:28:21 2016 +0200 updated commit c9c1c1d5a462f85e8001a45218f24102583d7aee Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Thu Oct 20 14:27:34 2016 +0200 docs(): updated image refs commit 5fa0f27963968d77bbbbb7edd973847ea72135e3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Wed Oct 19 14:33:04 2016 +0200 docs is almost done commit 6b988c90cb08563e2c27212338c2947e69f6fcc3 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 20:45:28 2016 +0200 almost done commit 17757c21ed813892ddb1f289f2e52613caf7bcef Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 16:45:48 2016 +0200 making progress on docs commit f06c815991dd81b8893912a6da04a17b80b63fda Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 14:30:55 2016 +0200 progress on new docs commit 5197237426252623de2d8b9cc22ddbbdbb240763 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 13:25:26 2016 +0200 making progress commit 33e2b6b617f16f65878141cf11e54b2817a2ea96 Merge: de385e5 ecb4a99 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Tue Oct 18 12:17:58 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit ecb4a99dd54aa39f17d9bf4d7e132a389812f8fd Author: Torkel Ödegaard <torkel@grafana.org> Date: Tue Oct 18 10:39:59 2016 +0200 keep urls for now commit de385e56d86b071cf2150ccf9f1aa06ec5187277 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:56:18 2016 +0200 more progress commit 8469ebc239ab2316cbbc01862e5026737f272f00 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 17:08:06 2016 +0200 progress on new docs commit e755f656b12534cfcb23bad11f1fa696e43f7428 Merge: 4644a35 35cce3b Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:27 2016 +0200 Merge branch 'new-docs' of github.com:grafana/grafana into new-docs commit 4644a35102555204787e91041b50dcbfe0f7a213 Merge: 25c4bef 977cdd5 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Mon Oct 17 12:21:11 2016 +0200 Merge branch 'master' of github.com:grafana/grafana into new-docs commit 35cce3bef802fac020a53693b02c112a91a096fc Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 17 09:31:17 2016 +0200 progress on #6170 commit 25c4bef629de7d77218ba95cc3bd25fb50bb19d6 Author: Torkel Ödegaard <torkel.odegaard@gmail.com> Date: Sun Oct 16 15:05:30 2016 +0200 fix for osx commit 6c6b52f975630be87da23dd51beafaecb820cec2 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 16 12:56:39 2016 +0200 progress on new docs commit 6a09633981ab26191d5542dbe3a788846ac6b73d Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 15 11:39:49 2016 +0200 progress on new docs commit 7d533fbc23e41b86fd1ba9c955dd17ae1ad977e5 Author: Torkel Ödegaard <torkel@grafana.org> Date: Mon Oct 10 09:25:12 2016 +0200 making progress on new docs site commit 50392ce98edfa201977716e92e4a86f9d48ae386 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sun Oct 9 20:02:28 2016 +0200 feat(new docs): progress on new docs site commit 81a3d3d0952d3a5d790412e90d01ac5a247e0686 Author: Torkel Ödegaard <torkel@grafana.org> Date: Fri Oct 7 07:52:11 2016 +0200 new docs site experiment commit 704adc98664665b3624087ab38ce29fc9da005f1 Author: Torkel Ödegaard <torkel@grafana.org> Date: Sat Oct 1 20:46:53 2016 +0200 new docs poc
2016-10-21 04:01:34 -05:00
+++
2015-11-02 01:17:23 -06:00
# Dashboard JSON model
2015-11-02 01:17:23 -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
1. Click on `Manage dashboard` menu on the top navigation bar
1. 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:
> **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
```json
2015-11-02 01:17:23 -06:00
{
"id": null,
"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,
"graphTooltip": 1,
"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-05-08 14:25:45 -05:00
"refresh": "5s",
"schemaVersion": 17,
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 |
| ----------------- | ----------------------------------------------------------------------------------------------------------------- |
| **id** | unique numeric identifier for the dashboard. (generated by the db) |
| **uid** | unique dashboard identifier that can be generated by anyone. string (8-40) |
| **title** | current title of dashboard |
| **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` |
| **editable** | whether a dashboard is editable or not |
| **graphTooltip** | 0 for no shared crosshair or tooltip (default), 1 for shared crosshair, 2 for shared crosshair AND shared tooltip |
| **time** | time range for dashboard, i.e. last 6 hours, last 7 days, etc |
| **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 |
| **refresh** | auto-refresh interval |
| **schemaVersion** | version of the JSON schema (integer), incremented each time a Grafana update brings changes to said schema |
| **version** | version of the dashboard (integer), incremented each time the dashboard is updated |
| **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
Panels are the building blocks of a dashboard. It consists of data source 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 depend on the panel type. Following is an example of panel JSON of a text panel.
```json
"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"
}
```
### Panel size and position
2018-02-21 03:47:14 -06:00
The gridPos property describes the panel size and position in grid coordinates.
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`.
2018-03-30 09:42:48 -05:00
The grid has a negative gravity that moves panels up if there is empty space above a panel.
2015-11-02 02:21:59 -06:00
### timepicker
```json
"timepicker": {
"collapse": false,
"enable": true,
"notice": false,
"now": true,
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"status": "Stable",
"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 |
| **type** | TODO |
2015-11-02 02:21:59 -06:00
### templating
2018-03-30 09:47:51 -05:00
The `templating` field contains an array of template variables with their saved values along with some other metadata, for example:
```json
"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,
"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)",
"refresh": false,
"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 each representing one template variable |
| **allFormat** | format to use while fetching all values from data source, eg: `wildcard`, `glob`, `regex`, `pipe`, etc. |
| **current** | shows current selected variable text/value on the dashboard |
| **data source** | shows data source 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 data source |
| **name** | name of variable |
| **options** | array of variable text/value pairs available for selection on dashboard |
| **query** | data source query used to fetch values for a variable |
| **refresh** | TODO |
| **regex** | TODO |
| **type** | type of variable, i.e. `custom`, `query` or `interval` |