Skip to content

Updating a dashboard for fun and profit

Amnon Heiman edited this page Mar 26, 2019 · 8 revisions

Adding a dashboard

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:

  1. Click the dashboard setting on top, and choose "View JSON"
  2. Copy the JSON and Paste it into a new JSON file, e.g. grafana/scylla-dash-per-server.new.json
  3. 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" to null.

example:

{
    "dashboard": {
        "id": null,
        "title": "Scylla Per Server Metrics",
        "originalTitle": "Scylla Per Server Metrics",
        "tags": [
...
  1. 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
  1. send a pull request with the new dashboard

Using templated 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 and generate-dashboards.sh

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

How to add entries to a template using make_dashboards.py

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.

Using the reverse mode to minimize a template

The -r mode in make_dashboards.py takes a dashboard and a type.json file and create a template from them.

  1. Copy the dashboard (not the template) you want to add entities to.
  2. Add the full entities definitions to the file (row, panels, etc').
  3. Add class properties to the added entities.
  4. Run make_dashboard.py with -r flag.
  5. 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.