API Stability Long-Term

The generateParserFromTemplate() GraphQL query is used to generate an unsaved parser from a YAML template.

Syntax

Below is the syntax for generateParserFromTemplate():

graphql
generateParserFromTemplate(
    input: GenerateParserFromTemplateInput!
  ): UnsavedParser!

For the GenerateParserFromTemplateInput input see Given Datatypes, the section below. For indicating which parameters of UnsavedParser you want, see the next section, Returned Datatypes.

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

Show:
graphql
query {
  generateParserFromTemplate(
    input: {yamlTemplate: "favorite-yaml-template"}
  ) {
    name, 
    script,
    fieldsToBeRemovedBeforeParsing
  }
}

Given Datatypes

GenerateParserFromTemplateInput() has its one required parameter: yamlTemplate with a datatype YAML, which is a scalar.

Returned Datatypes

The UnsavedParser() datatype has several parameters. Below is a list of them, along with a description of each:

Table: UnsavedParser

ParameterTypeRequiredDefaultStabilityDescription
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: Apr 2, 2025
descriptionstring  Long-TermA description of the parser.
fieldsToBeRemovedBeforeParsing[string]yes Long-TermA list of fields that will be removed from the event before it's parsed. These fields aren't included om usage calculation.
fieldsToTag[string]yes Long-TermA list of fields that are used as tags.
namestringyes Long-TermThe name of the unsaved parser.
scriptstringyes Long-TermThe parser script that is executed for each incoming event.
testCases[ParserTestCase]yes Long-TermTest cases that can be used to help verify that the parser works as expected. See ParserTestCase.