The createDashboardFromTemplateV2() GraphQL mutation field may be used to create a dashboard in LogScale from a YAML template.

For more information on creating dashboards, see the Create Dashboards and Widgets documentation page. You may also want to look at the Dashboards & Widgets page for related information.

Syntax

Below is the syntax for the createDashboardFromTemplateV2() mutation field:

graphql
createDashboardFromTemplateV2(
      input: CreateDashboardFromTemplateV2Input!
   ): Dashboard!

In the example below, for the YAML template, ellipses are shown instead to save space:

Raw
graphql
mutation {
  createDashboardFromTemplateV2(input:
      { viewName: "humio",
        name: "my-fancy-dashboard",
        yamlTemplate: "..."
      } )
  { id }
}
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 {
  createDashboardFromTemplateV2(input:
      { viewName: \"humio\",
        name: \"my-fancy-dashboard\",
        yamlTemplate: \"...\"
      } )
  { id }
}"
}
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 {
  createDashboardFromTemplateV2(input:
      { viewName: \"humio\",
        name: \"my-fancy-dashboard\",
        yamlTemplate: \"...\"
      } )
  { id }
}"
}
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 { ^
  createDashboardFromTemplateV2(input: ^
      { viewName: \"humio\", ^
        name: \"my-fancy-dashboard\", ^
        yamlTemplate: \"...\" ^
      } ) ^
  { id } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createDashboardFromTemplateV2(input:
      { viewName: \"humio\",
        name: \"my-fancy-dashboard\",
        yamlTemplate: \"...\"
      } )
  { id }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $INGEST_TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $json = '{"query" : "mutation {
  createDashboardFromTemplateV2(input:
      { viewName: \"humio\",
        name: \"my-fancy-dashboard\",
        yamlTemplate: \"...\"
      } )
  { id }
}"
}';
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 {
  createDashboardFromTemplateV2(input:
      { viewName: \"humio\",
        name: \"my-fancy-dashboard\",
        yamlTemplate: \"...\"
      } )
  { id }
}"
}'''

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 {
  createDashboardFromTemplateV2(input:
      { viewName: \"humio\",
        name: \"my-fancy-dashboard\",
        yamlTemplate: \"...\"
      } )
  { id }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL/graphql',
  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": {
    "createDashboardFromTemplateV2": {
      "id": "H9HVDeyfpru69mbwQzSITrEc1p3RRhFl"
    }
  }
}

Given Datatypes

For the input CreateDashboardFromTemplateV2Input, there are a few parameters. Below is a list of them along with their a brief description of each:

Table: CreateDashboardFromTemplateV2Input

ParameterTypeRequiredDefaultDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
Table last updated: Sep 17, 2024
namestringyes The name of the dashboard.
viewNamestringyes The name of the view of the dashboard.
yamlTemplateyamlyes A template that can be used to recreate the dashboard.

Returned Datatypes

The returned datatype Dashboard has its own parameters. Below is a list of them along with their datatypes and a description of each:

Table: Dashboard

ParameterTypeRequiredDefaultDescription
Some arguments may be required, as indicated in the Required column. For some fields, this column indicates that a result will always be returned for this column.
allowedActions[AssetAction]yes The allowed asset actions. See AssetAction Table). This is feature is a preview and may be changed.
assetTypeAssetTypeyes The related asset type. See AssetType Table). This has been deprecated and will be removed in LogScale version 1.136.
defaultFilterDashboardFilter  The default filter used with the dashboard (see DashboardFilter Table).
defaultSharedTimeEnabledbooleanyes Whether the shared time by default is enabled.
defaultSharedTimeEndstringyes The default shared ending time.
defaultSharedTimeStartstringyes The default shared starting time.
descriptionstring  A description of the dashboard.
displayNamestringyes The display name of the dashboard.
filters[DashboardFilter]yes The filters used with the dashboard. See DashboardFilter.
idstringyes The unique identifier for the dashboard.
isStarredbooleanyes Whether the dashboard is marked with a star.
labels[string]yes Any labels associated with the dashboard.
namestringyes The name of the dashboard.
packagePackageInstallationyes The package, if there is one, in which the dashboard is included (see PackageInstallation Table).
packageIdVersionedPackageSpecifieryes The unique identifiers of the package. VersionedPackageSpecifier is a scalar.
parameters[DashboardParameter]yes List of dashboard parameters (see DashboardParameter Table).
readOnlyTokens[DashboardLink]yes List of tokens used to access the dashboard without logging in. Useful for wall mounted dashboards or public dashboards. See DashboardLink.
searchDomainSearchDomainyes The search domain for the dashboard. See SearchDomain.
sections[Section]yes The sections for the dashboard. See Section.
yamlTemplatestringyes A YAML formatted string that describes the dashboard. It does not contain links or permissions, and is safe to share and use for making copies of a dashboard. This replaced templateYaml starting in LogScale version 1.165.
timeJumpSizeInMsinteger  The skip time in milliseconds for the dashboard.
updateFrequencyDashboardUpdateFrequencyTypeyes The frequency in which dashboard is updated. See the explanations under the DashboardParameter.
widgets[Widget]yes Widgets for the dashboard (see Widget Table).