Summary

The generateScheduledSearchFromTemplate() GraphQL query parses a YAML scheduled search template and returns an unsaved, in-memory UnsavedScheduledSearch object. 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
generateScheduledSearchFromTemplate(
      input: GenerateScheduledSearchFromTemplateInput!
   ): UnsavedScheduledSearch!

Provide the repository or view name as viewName and the full YAML specification of the scheduled search as yamlTemplate. Both fields are required. See Input Parameters and Returned Values for details.

Example

Raw
graphql
query {
  generateScheduledSearchFromTemplate(
    input: {viewName: "company-http", 
            yamlTemplate: "xxxx"}
  ) {
    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 {
  generateScheduledSearchFromTemplate(
    input: {viewName: \"company-http\", 
            yamlTemplate: \"xxxx\"}
  ) {
    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 {
  generateScheduledSearchFromTemplate(
    input: {viewName: \"company-http\", 
            yamlTemplate: \"xxxx\"}
  ) {
    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 { ^
  generateScheduledSearchFromTemplate( ^
    input: {viewName: \"company-http\",  ^
            yamlTemplate: \"xxxx\"} ^
  ) { ^
    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 {
  generateScheduledSearchFromTemplate(
    input: {viewName: \"company-http\", 
            yamlTemplate: \"xxxx\"}
  ) {
    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 {
  generateScheduledSearchFromTemplate(
    input: {viewName: \"company-http\", 
            yamlTemplate: \"xxxx\"}
  ) {
    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 {
  generateScheduledSearchFromTemplate(
    input: {viewName: \"company-http\", 
            yamlTemplate: \"xxxx\"}
  ) {
    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 {
  generateScheduledSearchFromTemplate(
    input: {viewName: \"company-http\", 
            yamlTemplate: \"xxxx\"}
  ) {
    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 and the full YAML specification of the scheduled search as yamlTemplate. Both fields are required.

Table: GenerateScheduledSearchFromTemplateInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
viewNameRepoOrViewNameyesย ย ย Name of the view of the scheduled search.
yamlTemplateYAMLyesย ย ย YAML specification 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: