createScheduledReport()

The createScheduledReport() GraphQL mutation field is used to create a scheduled report.

Syntax

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

graphql
createScheduledReport(
       input: CreateScheduledReportInput!
    ): ScheduledReport!

Below is an example of how this mutation field might be used:

Raw
graphql
mutation {
  createScheduledReport(input:
       { name: "my-report",
         viewName: "humio",
         enabled: true,
         description: "My Scheduled Report",
         dashboardId: "ILLF8JldGGP6tVspPuRtifX7ZGiHveGV",
         schedule: {cronExpression: "H 2 * * *", 
                    timeZone: "UTC+00:00", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: "something", value: "123" }],
         layout: { paperSize: "A4", paperOrientation: "Portrait",
                   paperLayout: "List",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: "bob@company.com"
      } )
  { 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 {
  createScheduledReport(input:
       { name: \"my-report\",
         viewName: \"humio\",
         enabled: true,
         description: \"My Scheduled Report\",
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\",
         schedule: {cronExpression: \"H 2 * * *\", 
                    timeZone: \"UTC+00:00\", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: \"something\", value: \"123\" }],
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\",
                   paperLayout: \"List\",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: \"bob@company.com\"
      } )
  { 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 {
  createScheduledReport(input:
       { name: \"my-report\",
         viewName: \"humio\",
         enabled: true,
         description: \"My Scheduled Report\",
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\",
         schedule: {cronExpression: \"H 2 * * *\", 
                    timeZone: \"UTC+00:00\", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: \"something\", value: \"123\" }],
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\",
                   paperLayout: \"List\",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: \"bob@company.com\"
      } )
  { 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 { ^
  createScheduledReport(input: ^
       { name: \"my-report\", ^
         viewName: \"humio\", ^
         enabled: true, ^
         description: \"My Scheduled Report\", ^
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\", ^
         schedule: {cronExpression: \"H 2 * * *\",  ^
                    timeZone: \"UTC+00:00\",  ^
                    startDate: 1729781206587}, ^
         labels: [ ] ^
         parameters: [ { id: \"something\", value: \"123\" }], ^
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\", ^
                   paperLayout: \"List\", ^
                   showTitleHeader: true, showDescription: true,  ^
                   showTitleFrontpage: true, showParameters: true, ^
                   showExportDate: false, footerShowPageNumbers: true, ^
                   maxNumberOfRows: 20 } ^
         recipients: \"bob@company.com\" ^
      } ) ^
  { id } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createScheduledReport(input:
       { name: \"my-report\",
         viewName: \"humio\",
         enabled: true,
         description: \"My Scheduled Report\",
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\",
         schedule: {cronExpression: \"H 2 * * *\", 
                    timeZone: \"UTC+00:00\", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: \"something\", value: \"123\" }],
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\",
                   paperLayout: \"List\",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: \"bob@company.com\"
      } )
  { 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 {
  createScheduledReport(input:
       { name: \"my-report\",
         viewName: \"humio\",
         enabled: true,
         description: \"My Scheduled Report\",
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\",
         schedule: {cronExpression: \"H 2 * * *\", 
                    timeZone: \"UTC+00:00\", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: \"something\", value: \"123\" }],
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\",
                   paperLayout: \"List\",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: \"bob@company.com\"
      } )
  { 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 {
  createScheduledReport(input:
       { name: \"my-report\",
         viewName: \"humio\",
         enabled: true,
         description: \"My Scheduled Report\",
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\",
         schedule: {cronExpression: \"H 2 * * *\", 
                    timeZone: \"UTC+00:00\", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: \"something\", value: \"123\" }],
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\",
                   paperLayout: \"List\",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: \"bob@company.com\"
      } )
  { 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 {
  createScheduledReport(input:
       { name: \"my-report\",
         viewName: \"humio\",
         enabled: true,
         description: \"My Scheduled Report\",
         dashboardId: \"ILLF8JldGGP6tVspPuRtifX7ZGiHveGV\",
         schedule: {cronExpression: \"H 2 * * *\", 
                    timeZone: \"UTC+00:00\", 
                    startDate: 1729781206587},
         labels: [ ]
         parameters: [ { id: \"something\", value: \"123\" }],
         layout: { paperSize: \"A4\", paperOrientation: \"Portrait\",
                   paperLayout: \"List\",
                   showTitleHeader: true, showDescription: true, 
                   showTitleFrontpage: true, showParameters: true,
                   showExportDate: false, footerShowPageNumbers: true,
                   maxNumberOfRows: 20 }
         recipients: \"bob@company.com\"
      } )
  { 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": {
    "createScheduledReport": {
      "id": "5xn2djAxMHiFPEWnbXTtg6IS5lKggn3f"
    }
  }
}

Given Datatypes

For CreateScheduledReportInput), there are a few parameters. Below is a list of them:

Table: CreateScheduledReportInput

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
dashboardIdstringyes The unique identifier of the dashboard for which the report was created.
descriptionstringyes A description of the scheduled report.
enabledbooleanyes Flag indicating whether the scheduled report is enabled.
labels[string]yes Labels attached to the scheduled report.
layoutCreateScheduledReportLayoutInputyes Layout of the scheduled report. See CreateScheduledReportLayoutInput.
namestringyes The name of the scheduled report.
parameters[CreateScheduledReportParameterValueInput]yes A list of parameter value configurations. See CreateScheduledReportParameterValueInput.
passwordstring  The password used to protect any generated reports.
recipients[string]yes A list of recipients who should receive an email with the generated report.
scheduleCreateScheduledReportScheduleInputyes The schedule by which to run the report. See CreateScheduledReportScheduleInput.
timeIntervalFromstring  The start of the relative time interval for the dashboard.
viewNamestringyes The name of the view of the scheduled report.

Returned Datatypes

As indicated by the syntax above, this mutation will return data using the datatype, ScheduledReport. Below is the parameter of that datatype:

Table: ScheduledReport

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: Oct 3, 2024
allowedActions[AssetAction]yes Allowed asset actions. This is a preview and subject to changes. See AssetAction.
createdByUser  User who created the report. See User.
creationDatestringyes Date when the report was created.
DashboardDashboardyes The dashboard for which the report was created. See TEXT.
dashboardIdstringyes The unique identifier of the dashboard for which the report was created.
descriptionstringyes Description of the scheduled report.
enabledbooleanyes Whether the scheduled report is enabled.
idstringyes The unique identifier of the scheduled report.
isPasswordDefinedbooleanyes Whether a password is defined for the report.
labels[string]yes Labels attached to the scheduled report.
lastExecutionErrors[string]yes Last errors encountered while generating the scheduled report.
lastExecutionWarnings[string]yes Last warnings encountered while generating the scheduled report.
layoutScheduledReportLayoutyes Layout of the scheduled report. See ScheduledReportLayout.
namestringyes The name of the scheduled report.
parameters[ParameterValue]yes List of parameter value configurations. See ParameterValue.
recipients[string]yes List of recipients who should receive an email with the generated report.
scheduleScheduleyes The schedule by which to run the report. See Schedule.
statusstringyes Status of the latest report execution.
timeIntervalStartstring  Start of the relative time interval for the dashboard.
timeOfLastReportExecutionlong  Unix timestamp for the last report execution. The timestamp only indicates an attempt, not if it was successful.
timeOfNextPlannedReportExecutionlong  Unix timestamp for the next planned report execution.