Grafana Dashboard Configurations

Automatically loading Grafana dashboard configurations

Automatically loading Grafana dashboard configurations

The DC/OS Monitoring service can be configured to automatically load Grafana dashboard configurations from a Git repository.

Save Grafana dashboard configurations

You should save your Grafana dashboard configurations (JSON format) in a Git repository. Assume that the repository is https://github.com/company/dashboard-configs.

You can put the Grafana dashboard configurations in a subfolder in the repository. For instance, https://github.com/company/dashboard-configs/production.

{
  "grafana": {
    "dashboard_config_repository": {
      "url": "https://github.com/company/dashboard-configs",
      "path": "/production"
    }
  }
}

The Git repository can be either public or private. If the Git repository is private, you will need to configure the credentials to access the Git repository (see below).

NOTE: If enabled, the set of default dashboards shipped with the service is from the Mesosphere-maintained Git repository `https://github.com/dcos/grafana-dashboards`. These dashboards are updated with DC/OS Monitoring service releases. If you would like to use the most up-to-date version of these dashboards that has not yet been released, you can configure the repository url to point to `https://github.com/dcos/grafana-dashboards`. The `grafana.default_dashboards` option should be set to `false`. As it is a public repository, there is no need to set up the `credentials`.

{
  "grafana": {
    "default_dashboards": false,
    "dashboard_config_repository": {
      "url": "https://github.com/dcos/grafana-dashboards",
      "path": "/dashboards"
    }
  }
}

Create secrets for Git repository credentials

If the Git repository containing the Grafana dashboard configurations is private, you will need to configure the secrets first. Currently, the following Auth types are supported.

IMPORTANT: If the Git repository contains submodules, all the submodules must use the same Auth type as what is used for the repository. For example, if HTTP Auth is configured for the Git repository, all of the submodules in the repository's `.gitmodules` file must use the `https` URL scheme.

HTTP Auth

dcos security secrets create --value=<GITHUB_USERNAME> githubusername-secret
dcos security secrets create --value=<GITHUB_PASSWORD> githubpassword-secret

For GitHub, the password can be the API token.

Create a custom option file (options.json) like the following. You can omit the credentials section if the Git repository is public.

{
  "grafana": {
    "dashboard_config_repository": {
      "url": "https://github.com/company/dashboard-configs",
      "path": "/production",
      "credentials": {
        "username_secret": "githubusername-secret",
        "password_secret": "githubpassword-secret"
      }
    }
  }
}

SSH Auth

dcos security secrets create -f <PATH_TO_PRIVATE_KEY> gitsshkey-secret

For GitHub, you must add the Deployment Key (i.e., the public key) to the repository.

Create a custom option file (options.json) like the following.

{
  "grafana": {
    "dashboard_config_repository": {
      "url": "git@github.com:company/dashboard-configs.git",
      "path": "/production",
      "credentials": {
        "deploy_key_secret": "gitsshkey-secret"
      }
    }
  }
}

NOTE: You will have to use `git@github.com:/.git` instead of `https` as the scheme of the URL.

Fetching from a branch in a Git repository

By default, the service will fetch from the master branch (that is, refs/heads/master) of the Git repository.

If you want to fetch the Grafana dashboard configurations from another branch in a Git repository, you can set the reference_name field:

{
  "grafana": {
    "dashboard_config_repository": {
      "url": "https://github.com/company/dashboard-configs",
      "path": "/production",
      "reference_name": "refs/heads/my_branch"
    }
  }
}

Install DC/OS Monitoring service

Then, install the service:

dcos package install dcos-monitoring --options=options.json

The Grafana dashboards defined in the repository will be automatically loaded when the service finishes deploying. You can go to the Grafana UI to verify.

Triggering a reload of Grafana dashboard configurations

It is possible to trigger a reload of the Grafana dashboard configurations after the service is installed.

dcos monitoring plan start reload-grafana-dashboard-configs