Dashboard provisioning

Hi there,

I am trying to use the new provisioning features of Grafana 5.0 for dashboard creation. Reading http://docs.grafana.org/v5.0/administration/provisioning/#dashboards it is not clear where the dashboards json files should be saved and with which filename. At the moment I have the files placed under /var/lib/grafana/dashboards as suggested in the documentation and set in the provisioning/dashboards/dashboards.yaml file, however no dashboard appears to be loaded.

What is the correct structure over there?

Thanks in advance,
Dimitris

Hi,

Which 5.0 pre version are you using?

There are a config variable for provisioning that specifies where to look for provisioning .yaml files. Per default this are configured to conf/provisioning directory. You’ll then put your dashboards.yaml in `conf/provisioning/dashboards directory. You can see that there are a few example files in Grafana code base.

Please make sure to restart Grafana after you added your yaml files. Also, check the Grafana server log.

Marcus

Hey Marcus

Thanks for the clarification.

I am running Grafana v5.0.0-beta4 (commit: 1de8891). It looks like my issue was an invalid dashboards.yaml at conf/provisioning/dashboards. It would be nice to add some relevant warnings in the logs in similar cases, since for me it was failing silently. An info message in case of successful loading could also be very useful.

Cheers,
Dimitris

Hi,

Great to hear that you sorted it out :+1:

Just looked in the source code and it seems like we don’t log anything if failing to parse yaml files. Gonna forward the feedback regarding this so that we can fix it. Thanks for the feedback!

Marcus

I am using the same grafana version as above stated.
I have my all.yml -> /etc/grafana/provisioning/all.yml

apiVersion: 1

providers:
- name: 'dev'
  orgId: 1
  folder: ''
  type: file
  disableDeletion: false
  editable: false
  options:
    path: /var/lib/grafana/dashboards

All the json file of the dashboard templates are in /var/lib/grafana/dashboards. But i do not see the dashboards loaded. Please help.

Then you need to change the provisioning configuration parameter to point to /etc/grafana/provisioning. Then you need to have the all.yml in a subfolder named dashboards /etc/grafana/provisioning/dashboards/all.yml.

Marcus

Hi,
I am getting the below error in logs after your suggested changes:
t=2018-04-27T04:50:46-0500 lvl=eror msg="failed to load dashboard from " logger=provisioning.dashboard type=file name=local-dev file=/var/lib/grafana/dashboards/CS-Collectd.json error=“Dashboard title cannot be empty”

CS-Collectd.json looks like this and it has title field

{
  "dashboard": {
    "annotations": {
      "list": []
    },
    "editable": true,
    "gnetId": null,
    "graphTooltip": 0,
    "hideControls": false,
    "id": null,
    "links": [],
    "refresh": false,
    "rows": [
      {
        "collapse": false,
        "height": 250,
        "panels": [
          {
            "aliasColors": {},
            "bars": false,
            "datasource": "{{ item.datasource }}",
            "fill": 1,
            "id": 12,
            "legend": {
              "alignAsTable": true,
              "avg": true,
              "current": true,
              "max": true,
              "min": true,
              "show": true,
              "total": false,
              "values": true
            },
            "lines": true,
            "linewidth": 1,
            "links": [],
            "nullPointMode": "null",
            "percentage": false,
            "pointradius": 5,
            "points": false,
            "renderer": "flot",
            "seriesOverrides": [],
            "span": 12,
            "stack": false,
            "steppedLine": false,
            "targets": [
              {
                "refId": "A",
                "target": "aliasByNode($Stack.$ServiceType.{{ country_code }}.$DCType.$DC.servers.$Servers.collectd-cache.*, 6, 8)",
                "textEditor": false
              }
            ],
            "thresholds": [],
            "timeFrom": null,
            "timeShift": null,
            "title": "Collectd Cache Size",
            "tooltip": {
              "shared": true,
              "sort": 0,
              "value_type": "individual"
            },
            "type": "graph",
            "xaxis": {
              "mode": "time",
              "name": null,
              "show": true,
              "values": []
            },
            "yaxes": [
              {
                "format": "short",
                "label": null,
                "logBase": 1,
                "max": null,
                "min": null,
                "show": true
              },
              {
                "format": "short",
                "label": null,
                "logBase": 1,
                "max": null,
                "min": null,
                "show": true
              }
            ]
          }
        ],
        "repeat": null,
        "repeatIteration": null,
        "repeatRowId": null,
        "showTitle": false,
        "title": "Dashboard Row",
        "titleSize": "h6"
      },
      {
        "collapse": false,
        "height": 250,
        "panels": [
          {
            "aliasColors": {},
            "bars": false,
            "datasource": "{{ item.datasource }}",
            "fill": 1,
            "id": 13,
            "legend": {
              "alignAsTable": true,
              "avg": true,
              "current": true,
              "max": true,
              "min": true,
              "show": true,
              "total": false,
              "values": true
            },
            "lines": true,
            "linewidth": 1,
            "links": [],
            "nullPointMode": "null",
            "percentage": false,
            "pointradius": 5,
            "points": false,
            "renderer": "flot",
            "seriesOverrides": [],
            "span": 12,
            "stack": false,
            "steppedLine": false,
            "targets": [
              {
                "refId": "A",
                "target": "aliasByNode($Stack.$ServiceType.{{ country_code }}.$DCType.$DC.servers.$Servers.collectd-write_queue.*, 6, 8)",
                "textEditor": false
              }
            ],
            "thresholds": [],
            "timeFrom": null,
            "timeShift": null,
            "title": "Collectd Write Queue Size",
            "tooltip": {
              "shared": true,
              "sort": 0,
              "value_type": "individual"
            },
            "type": "graph",
            "xaxis": {
              "mode": "time",
              "name": null,
              "show": true,
              "values": []
            },
            "yaxes": [
              {
                "format": "short",
                "label": null,
                "logBase": 1,
                "max": null,
                "min": null,
                "show": true
              },
              {
                "format": "short",
                "label": null,
                "logBase": 1,
                "max": null,
                "min": null,
                "show": true
              }
            ]
          }
        ],
        "repeat": null,
        "repeatIteration": null,
        "repeatRowId": null,
        "showTitle": false,
        "title": "Dashboard Row",
        "titleSize": "h6"
      }
    ],
    "schemaVersion": 14,
    "style": "dark",
    "tags": [],
    "templating": {
      "list": [
        {
          "allValue": null,
          "current": {"value":"first-item"},
          "datasource": "{{ item.datasource }}",
          "hide": 0,
          "includeAll": false,
          "label": null,
          "multi": true,
          "name": "Stack",
          "options": [],
          "query": "*",
          "refresh": 1,
          "regex": "/^(?!icinga.*|carbon.*|CS.*|rg.*)/",
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        },
        {
          "allValue": null,
          "current": {"value":"first-item"},
          "datasource": "{{ item.datasource }}",
          "hide": 0,
          "includeAll": false,
          "label": null,
          "multi": true,
          "name": "ServiceType",
          "options": [],
          "query": "$Stack.*",
          "refresh": 1,
          "regex": "",
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        },
        {
          "allValue": null,
          "current": {"value":"first-item"},
          "datasource": "{{ item.datasource }}",
          "hide": 0,
          "includeAll": false,
          "label": null,
          "multi": true,
          "name": "DCType",
          "options": [],
          "query": "$Stack.$ServiceType.{{ country_code }}.*",
          "refresh": 1,
          "regex": "",
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        },
        {
          "allValue": null,
          "current": {"value":"first-item"},
          "datasource": "{{ item.datasource }}",
          "hide": 0,
          "includeAll": false,
          "label": null,
          "multi": true,
          "name": "DC",
          "options": [],
          "query": "$Stack.$ServiceType.{{ country_code }}.$DCType.*",
          "refresh": 1,
          "regex": "",
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        },
        {
          "allValue": null,
          "current": {"value":"first-item"},
          "datasource": "{{ item.datasource }}",
          "hide": 0,
          "includeAll": false,
          "label": null,
          "multi": true,
          "name": "Servers",
          "options": [],
          "query": "$Stack.$ServiceType.{{ country_code }}.$DCType.$DC.servers.*",
          "refresh": 1,
          "regex": "",
          "sort": 0,
          "tagValuesQuery": "",
          "tags": [],
          "tagsQuery": "",
          "type": "query",
          "useTags": false
        }
      ]
    },
    "time": {
      "from": "now-24h",
      "to": "now"
    },
    "timepicker": {
      "refresh_intervals": [
        "5s",
        "10s",
        "30s",
        "1m",
        "5m",
        "15m",
        "30m",
        "1h",
        "2h",
        "1d"
      ],
      "time_options": [
        "5m",
        "15m",
        "1h",
        "6h",
        "12h",
        "24h",
        "2d",
        "7d",
        "30d"
      ]
    },
    "timezone": "browser",
    "title": "COS-Collectd",
    "version": 2
  },
  "overwrite": true
}

Try stripping the top level dashboard and overwrite keys and include only the content of the dashboard value. You might also have to remove the key id from it.

2 Likes

Thank you. This worked. But the dashboard loads with a delay is this expected or do I need to install any additional plugins?

What do you mean by delay - everytime you load it in UI?

Marcus