Dashboard import and constant variable values

Hello there,

I’m trying to import a previously exported dashboard through the api/dashboards/db API.

Even if the exported var is available in the __inputs section of the JSON, it is not used and replaced by the ${VAR_TESTVARIABLE} value :

  "__inputs": [
    {
      "name": "DS_MY_CLOUDWATCH",
      "label": "my_cloudwatch",
      "description": "",
      "type": "datasource",
      "pluginId": "cloudwatch",
      "pluginName": "CloudWatch"
    },
    {
      "name": "VAR_TESTVARIABLE",
      "type": "constant",
      "label": "TestVariable",
      "value": "i-0b7a61efe2aa955ff",
      "description": ""
    }
  ],

When I import manually the dashboard, the var is correctly filled in and i have only to select the datasource.

I’m using Grafana 5.0.3 (commit: 91162f3) on CentOS 7.
Shall I open a bug on the github or is this something unsupported ?

Kind regards,
/Lenain

Hi,

An exported dashboard (dashboard -> share -> export -> view/save json) can only be imported through the UI page named import.

To create/update dashboard thru the http api for dashboard you need to have json model from dashboard settings -> view json or from a HTTP GET of dashboard from http api, see dashboard http api documentation for more information.

Marcus