-
Notifications
You must be signed in to change notification settings - Fork 143
Updating a dashboard for fun and profit
See the template section for templating your dashboards The easiest way to update a Grafana dashboard is using the GUI. The project dashboard files are stored under grafana dir, and push to Grafana using REST. Take the following steps to export your new dashboard design to the project files:
- Click the dashboard setting on top, and choose "View JSON"
- Copy the JSON and Paste it into a new JSON file, e.g.
grafana/scylla-dash-per-server.new.json
- update your new JSON file as follow
- add a
dashboard
tag (make sure to close it at the end of the file) - set the dashboard
"id"
tonull
.
example:
{
"dashboard": {
"id": null,
"title": "Scylla Per Server Metrics",
"originalTitle": "Scylla Per Server Metrics",
"tags": [
...
- run the new file via
json_reformat
and save to the old dashboard name
cat grafana/scylla-dash-per-server.new.json | json_reformat > grafana/scylla-dash-per-server.json
- send a pull request with the new dashboard
To reduce the redundancy on the json format, starting from version 2.1, we added templated dashboards. We use a type-file called types.json and add a class
attribute to each json object we want to use type from.
the load-grafana.sh
script will recognize that it is a template and will use the make_dashboards.py
utility to create the dashboard.
make_dashboards.py
is a utility that generates dashbaords from templates or help you update the template when working in reverse mode (the -r
flag).
Use the -h flag to get help information.
You can use the make_dashboards.py
to generate a single dashboard, but it's usually easier to use the
generate-dashboards.sh
wrapper.
When you're done changing an existing dashboard, run the generate-dashboards.sh
with the current version,
this will replace your existing dashboards.
For example, if you are changing a dashboard in Scylla Enterprise version 2018.1 run:
generate-dashboards.sh -v 2018.1
The make_dashboards.py uses the define class
as the base for the json object and then add or override any specific value.
The types are hierarchical, so a type definition can have a class attribute and it would use those attribute as its own base definition.
For example row in the type.json defined:
"base_row": {
"collapse": false,
"editable": true
},
"row": {
"class": "base_row",
"height": "250px"
}
In a Template it will be used like:
{
"class": "row",
"height": "150px",
"panels": [
]
}
The output will be:
{
"class": "row",
"collapse": false,
"editable": true
"height": "150px",
"panels": [
]
}
We can see that the template added the panels
attribute and override the height
attribute.
The -r
mode in make_dashboards.py takes a dashboard and a type.json file and create a template from them.
- Copy the dashboard (not the template) you want to add entities to.
- Add the full entities definitions to the file (row, panels, etc').
- Add class properties to the added entities.
- Run make_dashboard.py with -r flag.
- Compare the changes between the original template and the new one.
Tip you can use the -kt
(key tips) flag to see where your definitions are changed from the type definitions, and make sure you did that on purpose.