Summary

The updateDashboardFromTemplate() mutation replaces an existing dashboard's structure by applying a new YAML specification. The YAML defines the dashboard's panels, queries, and layout in full. This mutation overwrites the current configuration rather than merging with it. Identify the target dashboard using its unique id. Retrieve this value with the dashboardsPage() query. To create a new dashboard from a template, use createDashboardFromTemplateV2() instead.

Syntax

graphql
updateDashboardFromTemplate(
      input: UpdateDashboardFromTemplateInput!
   ): Dashboard!

The mutation accepts a single required input argument of type UpdateDashboardFromTemplateInput!. The input requires id, viewName, and yamlTemplate. The mutation returns a non-null Dashboard! object representing the updated dashboard.

Input parameters

The input object requires three fields. The id field identifies the dashboard to update; retrieve it from the dashboardsPage() query. The viewName field identifies the view or repository that owns the dashboard. It accepts the RepoOrViewName scalar. The yamlTemplate field is a YAML scalar containing the full specification. It replaces the dashboard's current panels, queries, and layout entirely.

Example

The following example uses an ellipsis (...) in place of the full YAML template to reduce length:

Raw
graphql
mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: "humio",
      id: "abc123",
      yamlTemplate: "..."
    }
  ) { id, name }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      yamlTemplate: \"...\"
    }
  ) { id, name }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      yamlTemplate: \"...\"
    }
  ) { id, name }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "mutation { ^
  updateDashboardFromTemplate( ^
    input: {  ^
      viewName: \"humio\", ^
      id: \"abc123\", ^
      yamlTemplate: \"...\" ^
    } ^
  ) { id, name } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      yamlTemplate: \"...\"
    }
  ) { id, name }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      yamlTemplate: \"...\"
    }
  ) { id, name }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      yamlTemplate: \"...\"
    }
  ) { id, name }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "mutation {
  updateDashboardFromTemplate(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      yamlTemplate: \"...\"
    }
  ) { id, name }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "updateDashboardFromTemplate": {
      "id": "abc123",
      "name": "top-survey"
    }
  }
}

Returned values

The mutation returns the updated Dashboard! object reflecting the state after the template is applied. The id field contains the dashboard's unique identifier. Pass it to subsequent mutations such as updateDashboard(), renameDashboard(), and deleteDashboardV3(). Fields such as widgets return nested types. See the linked reference pages for their available fields.