Summary

The createScheduledReportFromTemplate() mutation creates a scheduled report in a LogScale repository or view using a YAML template definition you supply. The YAML template encodes the report name, cron-based delivery schedule, recipient list, layout settings, and optional dashboard parameter overrides as a serialized string. Use this mutation when you want to define the report configuration as code rather than through the UI or a packaged library template. To update an existing template-based scheduled report, use updateScheduledReportFromTemplate().

Syntax

graphql
createScheduledReportFromTemplate(
      input: CreateScheduledReportFromTemplateInput!
   ): ScheduledReport!

The mutation accepts a single required input argument of type CreateScheduledReportFromTemplateInput!. The viewName and yamlTemplate fields are required. The name field is optional; when omitted, LogScale uses the name encoded in the YAML template. The mutation returns a non-null ScheduledReport! object representing the newly created report.

Example

Raw
graphql
mutation {
  createScheduledReportFromTemplate(
    input: { viewName: "our_view", 
             name: "our_report",
             "yamltemplate": "name: Sales\n ... " }
  ) { 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 {
  createScheduledReportFromTemplate(
    input: { viewName: \"our_view\", 
             name: \"our_report\",
             \"yamltemplate\": \"name: Sales\n ... \" }
  ) { 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 {
  createScheduledReportFromTemplate(
    input: { viewName: \"our_view\", 
             name: \"our_report\",
             \"yamltemplate\": \"name: Sales\n ... \" }
  ) { 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 { ^
  createScheduledReportFromTemplate( ^
    input: { viewName: \"our_view\",  ^
             name: \"our_report\", ^
             \"yamltemplate\": \"name: Sales\n ... \" } ^
  ) { id } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createScheduledReportFromTemplate(
    input: { viewName: \"our_view\", 
             name: \"our_report\",
             \"yamltemplate\": \"name: Sales\n ... \" }
  ) { 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 {
  createScheduledReportFromTemplate(
    input: { viewName: \"our_view\", 
             name: \"our_report\",
             \"yamltemplate\": \"name: Sales\n ... \" }
  ) { 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 {
  createScheduledReportFromTemplate(
    input: { viewName: \"our_view\", 
             name: \"our_report\",
             \"yamltemplate\": \"name: Sales\n ... \" }
  ) { 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 {
  createScheduledReportFromTemplate(
    input: { viewName: \"our_view\", 
             name: \"our_report\",
             \"yamltemplate\": \"name: Sales\n ... \" }
  ) { 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": {
    "createScheduledReportFromTemplate": {
      "id": "123abc"
    }
  }
}

Input Parameters

Provide the target view or repository name and a YAML-formatted string that encodes the report definition. The name field is optional; when provided, it overrides the name in the template. The following table describes each field:

Table: CreateScheduledReportFromTemplateInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
nameString    Optional name for the scheduled report. If not provided, the name in the template will be used.
viewNameStringyes   Name of the view of the scheduled report.
yamlTemplateYAMLyes   The YAML template for the scheduled report.

Returned Values

The mutation returns a non-null ScheduledReport! object representing the newly created report. The returned object includes the report name, description, enabled status, the associated dashboard identifier, the cron-based delivery schedule with time zone and optional start and end dates, the recipient list, assigned labels, the YAML template string, and the result of the most recent execution attempt.