Constant type inputs are not being substituted in dashboards v2

  • What Grafana version and what operating system are you using?
    Grafana v13

  • What are you trying to achieve?
    Dashboards schema v1 used to have constant type in inputs to substitute the variables in dashboards during the import process. When I attempt to import such dashboard in Grafana v13, constant type inputs are being ignored.

  • How are you trying to achieve it?
    Use the following dashboard v1 JSON model and attempt to import in Grafana v13.x:

{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    },
    {
      "name": "VAR_METRIC_NAME",
      "type": "constant",
      "label": "Choose a node exporter metric (eg: go_goroutines)",
      "value": "",
      "description": "Node exporter metric"
    }
  ],
  "__elements": {},
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "12.1.1"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    }
  ],
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": null,
  "links": [],
  "panels": [
    {
      "datasource": {
        "type": "prometheus",
        "uid": "${DS_PROMETHEUS}"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": 0
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          }
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 1,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "list",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "single",
          "sort": "none"
        }
      },
      "pluginVersion": "12.1.1",
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${DS_PROMETHEUS}"
          },
          "disableTextWrap": false,
          "editorMode": "builder",
          "expr": "${VAR_METRIC_NAME}",
          "fullMetaSearch": false,
          "includeNullMetadata": true,
          "instant": false,
          "legendFormat": "__auto",
          "range": true,
          "refId": "A",
          "useBackend": false
        }
      ],
      "title": "Test panel",
      "type": "timeseries"
    }
  ],
  "schemaVersion": 41,
  "tags": [],
  "templating": {
    "list": []
  },
  "time": {
    "from": "now-6h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "browser",
  "title": "Test dashboard",
  "uid": "d7969a18-70fb-407a-9346-b83f3d28f649",
  "version": 3,
  "weekStart": ""
}

During the import, put go_goroutines as the value for Choose a node exporter metric which should use it as query for Prometheus. However, you can check from panel query, the value is not being substituted.

  • What did you expect to happen?
    Constant type inputs are substituted in dashboards v2 as it was the case in dashboards v1.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Dashboard JSON model has been already posted above.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No

Finally, I could not find documentation on how to use the “constant” type inputs in dashboard v2 schema. Would be very helpful if someone has can point me to documentation or give me hints on how to have a similar feature in dashboard v2.

Cheers

hello @mahendrapaipuri you can try with grafana dashboard variable and used in your panel query.
ie.


Hello @infofcc3

Cheers for the reply. Yes, I am aware of this solution as well. However, this means users need to “manually” modify the dashboard after importing it which is not very convenient.

In Grafana v13, when I attempt to import the dashboard, UI asks me to set up constant type inputs but they are not being substituted. However, datasource inputs are being correctly substituted. So, I guess this should be a bug, right?!

Ahh, I get it!! There should be a hidden template variable in the Grafana dashboard for the inputs substitution to work. I confirm with a hidden template variable defined, it works as expected both on dashboard schema v1 and v2. In the earlier versions of Grafana, hidden template variable was not necessary for inputs to work and hence, the confusion. Sorry for the noise!!

Thanks for the help!