Rob Ronayne
Rob Ronayne

Reputation: 11

Grafana Dashboard Provisioning Error: "Dashboard title cannot be empty" Despite Correct JSON Format and File Mounting

Issue Summary

I am experiencing an issue with deploying a Grafana dashboard using Helm in a Kubernetes environment. Despite correctly formatting and mounting the JSON file for a dashboard, Grafana fails to load the dashboard, reporting that the "Dashboard title cannot be empty".

Environment

Problem Details

The problem appears to be that Grafana fails to recognize the dashboard JSON file, even though it is correctly formatted and placed in the correct directory.

Configurations

grafana/templates/grafana-dashboards.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboards
  namespace: monitoring
  labels:
    grafana_dashboard: "1"
data:
  pi-cluster-health.json: |-
    {{ .Files.Get "dashboards/pi-cluster-health.json" | indent 4 }}

grafana/dashboards/grafana-dashboards.yaml

{
    "dashboard": {
        "id": null,
        "title": "Raspberry Pi Cluster Health",
        "panels": [
            {
                "type": "graph",
                "title": "CPU Usage",
                "targets": [
                    {
                        "expr": "100 - (avg by(instance) (rate(node_cpu_seconds_total{mode='idle'}[5m])) * 100)",
                        "legendFormat": "{{`{{ instance }}`}}",
                        "refId": "A"
                    }
                ],
                "yaxes": [
                    {
                        "format": "percent",
                        "label": "CPU Usage",
                        "min": 0,
                        "max": 100
                    }
                ],
                "xaxis": {
                    "show": true
                },
                "gridPos": {
                    "h": 9,
                    "w": 12,
                    "x": 0,
                    "y": 0
                }
            }
        ],
        "schemaVersion": 16,
        "version": 0,
        "refresh": "5s"
    }
}

Verification Steps

ConfigMap Verification

Verified that the ConfigMap is correctly created and contains the JSON:

kubectl get configmap grafana-dashboards -n monitoring -o yaml

Output:

apiVersion: v1
data:
  pi-cluster-health.json: |-
    {
      "dashboard": {
        "id": null,
        "title": "Raspberry Pi Cluster Health",
        ...
    }

File Verification in Pod

Verified that the JSON file is correctly mounted in the Grafana pod:

kubectl exec -it <grafana-pod> -n monitoring -- /bin/sh
cat /var/lib/grafana/dashboards/pi-cluster-health.json

Output:

{
  "dashboard": {
    "id": null,
    "title": "Raspberry Pi Cluster Health",
    ...
}

Grafana Logs

Checked Grafana logs for errors:

kubectl logs -l app=grafana -n monitoring

Output:

logger=provisioning.dashboard type=file name=default t=2024-07-11T02:33:51.503463709Z level=error msg="failed to load dashboard from " file=/var/lib/grafana/dashboards/pi-cluster-health.json error="Dashboard title cannot be empty"

Observations

Despite the JSON file being correctly formatted and placed, Grafana logs indicate that the "Dashboard title cannot be empty". The title is clearly defined in the JSON file.

Upvotes: 0

Views: 122

Answers (0)

Related Questions