Mixed mode dashboard import

I am trying to import a dashboard which uses the “Mixed” datasource for most panels. Because we have multiple Grafana instances our automation will create the JSON with the correct datasources for each instance. I am having problems where the dashboard will import successfully but the datasources are all empty. We see errors such as "Datasource named was not found.

Backend data sources are Prometheus and our Grafana is v4.3.1. Both the templating and panels are not correctly registering the datasources. Here are some JSON snippets. I have confirmed data sources values match correctly.

I can upload our entire JSON but it is pretty large so I figured I would see if this was adequate. Please help.

"inputs": [
    {
        "name": "DS_W_NG1",
        "pluginId": "prometheus",
        "type": "datasource",
        "value": "ds w ng1"
    },
    {
        "name": "DS_C_NG1",
        "pluginId": "prometheus",
        "type": "datasource",
        "value": "ds c ng1"
    },
    {
        "name": "DS_P_NG1",
        "pluginId": "prometheus",
        "type": "datasource",
        "value": "ds p ng1"
    }
],

            "panels": [
                {
                    "aliasColors": {},
                    "bars": false,
                    "dashLength": 10,
                    "dashes": false,
                    "datasource": "-- Mixed --",
                    "fill": 1,
                    "height": "350px",
                    "id": 9,
                    "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": [],
                    "spaceLength": 10,
                    "span": 6,
                    "stack": false,
                    "steppedLine": false,
                    "targets": [
                        {
                            "datasource": "${DS_W_NG1}",
                            "expr": "java_lang_garbagecollector_collectioncount{pod=\"$pod\",package=\"$package\",name=\"ParNew\",location=~\"($location|all)\"}",
                            "format": "time_series",
                            "intervalFactor": 2,
                            "legendFormat": "{{instance}}",
                            "metric": "java_lang_garbagecollector_collectioncount",
                            "refId": "A",
                            "step": 4
                        },

    "templating": {
        "list": [
            {
                "allValue": null,
                "current": {},
                "datasource": "${DS_C_NG1}",
                "hide": 0,
                "includeAll": false,
                "label": "Pod",
                "multi": false,
                "name": "pod",
                "options": [],
                "query": "label_values(pod)",
                "refresh": 1,
                "regex": "",
                "sort": 1,
                "tagValuesQuery": "",
                "tags": [],
                "tagsQuery": "",
                "type": "query",
                "useTags": false
            },

Try upgrading to latest version, think this was fixed in v4.5 not sure

I have tried this on v4.6.1 without success. To simply this I am trying to focus on the getting the templating working first. I tried adding the “__inputs” array under the “dashboard” key in the JSON. When this is done the import fails completely. Would it help for you to get my entire JSON?

I was able to work but I had to remove the references to datasource variables such as DS_PROMETHEUS. My script which was modifying the JSON to the applicable datasources for each of our grafana instances already knew the datasources. Instead of inserting the datasource variables I simply inserted the name of the actual datasource. This has worked perfectly during the import. This solution will likely not work for everyone but my script already knew the available datasources for each instance and how to build out the panel metric entries for each. :confused:

Still loving prometheus + grafana :slight_smile: