Searching for results...

No results

Your search did not match anything from Mirantis documentation.
Check your spelling or try different keywords.

An error occurred

An error occurred while using the search.
Try your search again or contact us to let us know about it.

Newer documentation is now live.You are currently reading an older version.

Create custom dashboards in Grafana

You can add custom dashboards either using the Grafana user interface (UI) or declaratively:

  • UI method: use the Import feature, which stores dashboards directly in the Grafana database. For details, see official Grafana documentation.

  • Declarative method: store dashboards as JSON in Kubernetes ConfigMaps, which allows version-controlled, GitOps-friendly dashboard management.

To add custom dashboards in Grafana declaratively:

  1. Obtain the list of JSON file names accross all Grafana dashboard ConfigMaps:

    kubectl get configmaps -n stacklight -l dashboard-provider=default -o json | jq -r '.items[].data | keys[]'
    

    Example of system response:

    alertmanager.json
    clusters-overview.json
    …
    
  2. Obtain the list of all active dashboard titles and UIDs from the Grafana API:

    kubectl exec -n stacklight deploy/grafana -c grafana -- \
      curl -s "http://localhost:3000/api/search?type=dash-db" | \
      jq -r '.[] | "title: \(.title) [uid: \(.uid)]"'
    

    Example of system response:

    title: Alertmanager [uid: ae5441xus40lca]
    title: Clusters Overview [uid: de5441y5vnrwgd]
  3. In the stacklight namespace, create a ConfigMap containing the JSON file with dashboard details.

    Important

    Ensure that the following identifiers are unique across all Grafana dashboard ConfigMaps and do not conflict with existing identifiers verified in previous steps:

    • ConfigMap name

    • JSON file name

    • Dashboard title and UID inside JSON

  4. Add the dashboard-provider: default label to the ConfigMap.

    Note

    Removing this label from the ConfigMap removes the related Grafana dashboard.

Example ConfigMap for a custom Grafana dashboard:

apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboards-custom-myapp
  namespace: stacklight
  labels:
    dashboard-provider: default
data:
  myapp-overview.json: |
    {
      "editable": true,
      "panels": [],
      "time": {
        "from": "now-1h",
        "to": "now"
      },
      "title": "Myapp Overview",
      "uid": "myapp-overview",
      "version": 1
    }

The custom dashboard becomes available in Grafana shortly after the ConfigMap is created.