Summary

The createDashboardFromPackageTemplate() mutation creates a dashboard in a view by instantiating a dashboard template from an installed package. Install the package in the target view before calling this mutation. To create a dashboard from a standalone YAML specification, use createDashboardFromTemplateV2().

Syntax

graphql
createDashboardFromPackageTemplate(
      viewName: String!,
      packageId: VersionedPackageSpecifier!,
      dashboardTemplateName: String!,
      overrideName: String
   ): CreateDashboardFromPackageTemplateMutation!

The packageId argument accepts a VersionedPackageSpecifier scalar that combines the package namespace, name, and version in the format namespace/packageName@version, for example, humio/insights@0.0.14. The dashboardTemplateName argument identifies the specific template within that package. The following table describes all arguments.

The mutation returns a non-null CreateDashboardFromPackageTemplateMutation object. The dashboard.id field returns the ID of the new dashboard.

Example

Raw
graphql
mutation {
  createDashboardFromPackageTemplate(
        viewName: "humio", packageId: "humio/insights@0.0.14",
        dashboardTemplateName: "Hosts",
        overrideName: "Visitors"
        )
  { dashboard {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 {
  createDashboardFromPackageTemplate(
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\",
        dashboardTemplateName: \"Hosts\",
        overrideName: \"Visitors\"
        )
  { dashboard {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 {
  createDashboardFromPackageTemplate(
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\",
        dashboardTemplateName: \"Hosts\",
        overrideName: \"Visitors\"
        )
  { dashboard {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 { ^
  createDashboardFromPackageTemplate( ^
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\", ^
        dashboardTemplateName: \"Hosts\", ^
        overrideName: \"Visitors\" ^
        ) ^
  { dashboard {id}} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createDashboardFromPackageTemplate(
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\",
        dashboardTemplateName: \"Hosts\",
        overrideName: \"Visitors\"
        )
  { dashboard {id}}
}"
}'
    "$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 {
  createDashboardFromPackageTemplate(
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\",
        dashboardTemplateName: \"Hosts\",
        overrideName: \"Visitors\"
        )
  { dashboard {id}}
}";
$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 {
  createDashboardFromPackageTemplate(
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\",
        dashboardTemplateName: \"Hosts\",
        overrideName: \"Visitors\"
        )
  { dashboard {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 {
  createDashboardFromPackageTemplate(
        viewName: \"humio\", packageId: \"humio/insights@0.0.14\",
        dashboardTemplateName: \"Hosts\",
        overrideName: \"Visitors\"
        )
  { dashboard {id}}
}"
}
);


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": {
    "createDashboardFromPackageTemplate": {
      "dashboard": {
        "id": "abc123"
      }
    }
  }
}

Input Parameters

Provide the view name, versioned package identifier, and dashboard template name. The VersionedPackageSpecifier scalar for packageId takes the format namespace/packageName@version, for example, humio/insights@0.0.14. To find available dashboard templates in a package, call the repository() or repositories() queries and inspect the package details.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
dashboardTemplateName string yes   The name of the dashboard template in the package to instantiate. The name must match exactly as defined in the package manifest.
overrideName string     A custom name to assign to the new dashboard. When omitted, LogScale uses the template's default name from the package.
packageId VersionedPackageSpecifier yes   The identifier of the installed package containing the dashboard template. VersionedPackageSpecifier is a scalar in the format namespace/packageName@version, for example, humio/insights@0.0.14.
viewName string yes   The name of the view or repository where the package is installed. The package must be installed in this view before calling this mutation.

Returned Values

The mutation returns a CreateDashboardFromPackageTemplateMutation object containing the created dashboard. Use the returned dashboard.id value with subsequent mutations or queries.

Table: CreateDashboardFromPackageTemplateMutation Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
dashboardDashboardyes Long-Term  

The following table describes the Dashboard sub-datatype returned within the preceding type.