Summary

The generateScheduledSearchFromPackageTemplate() GraphQL query generates an unsaved, in-memory scheduled search from a library package template. Scheduled searches run a query on a fixed interval or cron schedule and fire actions on results — distinct from alerts, which are event-driven. Pass the result to createScheduledSearchV2() to save it.

Syntax

graphql
generateScheduledSearchFromPackageTemplate(
      input: GenerateScheduledSearchFromPackageTemplateInput!
   ): UnsavedScheduledSearch!

Provide the repository or view name as viewName, the versioned package identifier as packageId, and the template name as templateName. See Input Parameters and Returned Values for details.

Example

Raw
graphql
query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: "company-http", 
            packageId: "http-packers@1.23",
            templateName: "standard-aggregatealert-template"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}
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" : "query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: \"company-http\", 
            packageId: \"http-packers@1.23\",
            templateName: \"standard-aggregatealert-template\"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}"
}
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" : "query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: \"company-http\", 
            packageId: \"http-packers@1.23\",
            templateName: \"standard-aggregatealert-template\"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}"
}
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" : "query { ^
  generateScheduledSearchFromPackageTemplate( ^
    input: {viewName: \"company-http\",  ^
            packageId: \"http-packers@1.23\", ^
            templateName: \"standard-aggregatealert-template\"} ^
  ) { ^
    name,  ^
    description, ^
    queryString, enabled, ^
    schedule, timeZone, ^
    actions { ^
      id, name, isAllowedToRun ^
    }     ^
  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: \"company-http\", 
            packageId: \"http-packers@1.23\",
            templateName: \"standard-aggregatealert-template\"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}"
}'
    "$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 = "query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: \"company-http\", 
            packageId: \"http-packers@1.23\",
            templateName: \"standard-aggregatealert-template\"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}";
$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" : "query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: \"company-http\", 
            packageId: \"http-packers@1.23\",
            templateName: \"standard-aggregatealert-template\"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}"
}'''

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" : "query {
  generateScheduledSearchFromPackageTemplate(
    input: {viewName: \"company-http\", 
            packageId: \"http-packers@1.23\",
            templateName: \"standard-aggregatealert-template\"}
  ) {
    name, 
    description,
    queryString, enabled,
    schedule, timeZone,
    actions {
      id, name, isAllowedToRun
    }    
  }
}"
}
);


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();

Input Parameters

Provide the repository or view name as viewName, the versioned package identifier as packageId, and the template name within the package as templateName. All three are required.

Table: GenerateScheduledSearchFromPackageTemplateInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
packageIdVersionedPackageSpecifieryes   The id of the package that the scheduled search was installed as part of.
templateNameStringyes   The name of the scheduled search template in the package.
viewNameRepoOrViewNameyes   Name of the view of the scheduled search.

Returned Values

The result is a non-nullable UnsavedScheduledSearch object. Core fields include name, description (nullable), queryString, schedule (a non-nullable string using either an interval expression such as @every 5d or a standard cron pattern), timeZone (UTC offsets only — for example, UTC, UTC-01, or UTC+12:45; named time zones are not currently supported), searchIntervalSeconds, actions (a list of Action objects to fire on query result), labels, enabled, and triggerOnEmptyResult (a non-nullable boolean — when true, actions fire even when the query returns no events, which is useful for absence monitoring such as detecting missing heartbeats).

Several fields are conditional on queryTimestampType (a non-nullable QueryTimestampType enum — either EventTimestamp or IngestTimestamp). When queryTimestampType is EventTimestamp: backfillLimitV2 (nullable Int) caps the number of missed executions that are backfilled after a shutdown, preventing overload on restart; and searchIntervalOffsetSeconds (nullable Long) shifts the query window to account for ingestion delay. When queryTimestampType is IngestTimestamp: maxWaitTimeSeconds (nullable Long) sets the maximum time to wait for late-arriving events before executing the query, balancing freshness against completeness. The available fields are listed here:

Table: UnsavedScheduledSearch Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
actionsActionyes Long-Term List of Ids for actions to fire on query result.
backfillLimitV2Int  Long-Term User-defined limit, which caps the number of missed searches to backfill, e.g. in the event of a shutdown. Only present when 'queryTimestampType' is EventTimestamp.
descriptionString  Long-Term Description of the scheduled search.
enabledBooleanyes Long-Term Flag indicating whether the scheduled search is enabled.
labelsStringyes Long-Term Labels attached to the scheduled search.
maxWaitTimeSecondsLong  Long-Term Maximum number of seconds to wait for ingest delay. Only present when 'queryTimestampType' is IngestTimestamp.
nameStringyes Long-Term Name of the scheduled search.
queryStringStringyes Long-Term LogScale query to execute.
queryTimestampTypeQueryTimestampTypeyes Long-Term Timestamp type to use for the query.
scheduleStringyes Long-Term Interval or cron pattern describing the schedule to execute the query on. Intervals look like '@every 5d'.
scheduleEndLong  Long-Termadded in 1.268Unix timestamp in milliseconds for the latest time the scheduled search should execute.
scheduleStartLong  Long-Termadded in 1.268Unix timestamp in milliseconds for when the scheduled search should at earliest execute.
searchIntervalOffsetSecondsLong  Long-Term Offset of the search interval in seconds. Only present when 'queryTimestampType' is EventTimestamp.
searchIntervalSecondsLongyes Long-Term Search interval in seconds.
timeZoneStringyes Long-Term Time zone of the schedule. Currently this field only supports UTC offsets like 'UTC', 'UTC-01' or 'UTC+12:45'.
triggerOnEmptyResultBooleanyes Long-Term Flag indicating whether the scheduled search should trigger when it finds en empty result (no events).