Steps to import the JSON of a Grafana dashboard:

  1. Create a ConfigMap including the dashboard JSON
  2. Create a new Grafana dashboardProvider in the Grafana helmRelease values
  3. Map the new dashboardProvider to the new ConfigMap in the Grafana helmRelease values

ConfigMap definition

Create a new ConfigMap. The name of the ConfigMap should represent the category or folder of dashboards it contains; in the example below, this is graph-services. The ConfigMap must be in the same namespace as the Grafana helmRelease. The data of the ConfigMap should define a JSON multi-line string. The value of the multi-line string should be the JSON exported from a Grafana dashboard. Optionally, add the label grafana_dashboard: "1" if you also use the Grafana sidecar for auto-discovery; it is not required when using dashboardsConfigMaps.

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    grafana_dashboard: "1"
  name: graph-services
  namespace: monitoring
data:
  graph-services-response-times.json: |-
    {
      "annotations": {
        "list": [
          {
            "builtIn": 1,
            "datasource": {
              "type": "datasource",
              "uid": "grafana"
            },
            ...

You can also include multiple dashboard JSON files in the ConfigMap by adding additional key-value pairs. For example:

apiVersion: v1
kind: ConfigMap
metadata:
  labels:
    grafana_dashboard: "1"
  name: graph-services
  namespace: monitoring
data:
  graph-services-response-times.json: |-
    # Dashboard 1 JSON goes here
  graph-services-error-rates.json: |-
    # Dashboard 2 JSON goes here

New dashboardProvider in the Grafana helmRelease values

Every ConfigMap containing dashboards must have an individual dashboardProvider defined for it in the Grafana helmRelease values.

Add a new dashboardProvider in the Grafana helmRelease values under dashboardProviders.dashboardproviders.yaml. The dashboardProvider name must be unique and should match the ConfigMap name for consistency. The same name must also be used as the path suffix in options.path (e.g. /var/lib/grafana/dashboards/graph-services) and as the key in dashboardsConfigMaps, so that the provider, path, and ConfigMap mapping all align. The folder in which the dashboard will be available in Grafana should also be defined. This folder does not need to already exist in Grafana, but the value should not be empty; otherwise, the dashboard is saved in the General folder, where it may be harder to find among other unsorted dashboards.

Set foldersFromFilesStructure to false to decouple the Grafana folder name from the ConfigMap name, allowing the displayed folder name to differ from the provider name.

 - name: graph-services
   orgId: 1
   folder: 'Graph Services'
   type: file
   disableDeletion: true
   editable: false
   options:
     path: /var/lib/grafana/dashboards/graph-services
     foldersFromFilesStructure: false

Mapping the new dashboardProvider to the new ConfigMap

The new dashboardProvider should now be mapped to the new ConfigMap containing the dashboard JSON definition. In the Grafana helmRelease under dashboardsConfigMaps, add a new key-value pair, with the new dashboardProvider’s name as the key and the new ConfigMap’s name as the value.

graph-services: "graph-services"

Apply the ConfigMap, install the Grafana helmRelease, and your newly imported dashboard should be available in Grafana!