API Stability Long-Term

The createParserV2() GraphQL mutation may be used to create a parser in LogScale.

For more information on creating a parser, see the Creating a Parser documentation page. You may also want to look at the Parsing Data and Parsing Log Data pages for related information.

Syntax

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

graphql
createParserV2(
      input: CreateParserInputV2!
   ): Parser!

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

Show:
graphql
mutation {
  createParserV2(input:
      { repositoryName: "humio",
        name: "myKvParser",
        script: "kvParse()",
        testCases: [{
          event: {rawString: "key=value"}, 
          outputAssertions: [{outputEventIndex: 0, assertions: {fieldsHaveValues: [{fieldName: "key", expectedValue: "value"}]}}],
        }],
        fieldsToTag: [],
        fieldsToBeRemovedBeforeParsing: []
      })
  { id }
}

Given Datatypes

For the given datatype, CreateParserInputV2, there are several parameters that may be given. Below is a list of them:

Table: CreateParserInputV2

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: Mar 28, 2025
allowOverwritingExistingParserboolean false Allows saving a parser with a name that is already in use, by overwriting the parser that previously had the name.
fieldsToTag[string]yes  Fields that are used as tags.
fieldsToBeRemovedBeforeParsing[string]yes  A list of fields that will be removed from the event before it's parsed. These fields will not be included when calculating usage.
languageVersionmultiple {name: ”legacy“} A specific language version. The multiple datatype consists of LanguageVersionInputType = {name: 'legacy'}. See LanguageVersionInputType.
namestringyes  The name to use for the parser.
repositoryNameRepoOrViewNameyes  The repository where the parser is located. RepoOrViewName is a scalar.
scriptstringyes  The parser script that is executed for every incoming event.
testCases[ParserTestCaseInput]yes  Test cases that can be used to help verify that the parser works as expected. See ParserTestCaseInput.

Returned Datatypes

The returned datatype Parser has many parameters. Below is a list of them along:

Table: Parser

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: Mar 26, 2025
assetTypeAssetTypeyes Long-TermThe type of asset. See AssetType. This is deprecated and will be removed in LogScale 1.142.
descriptionstring  Long-TermA description of the parser.
displayNamestringyes Long-TermThe full name of the parser, including package information if part of an application.
fieldsToBeRemovedBeforeParsing[string]yes Long-TermA list of fields that will be removed from the event before it's parsed. These fields will not be included when calculating usage.
fieldsToTag[string]yes Long-TermThe fields that are used as tags.
idstringyes Long-TermThe unique identifier of the parser.
isBuiltInbooleanyes Long-TermTrue if the parser is one of LogScale's built-in parsers.
languageVersionLanguageVersionyes Long-TermThe language version used by the parser. See LanguageVersion.
namestringyes Long-TermThe name of the parser.
scriptstringyes Long-TermThe parser script that is executed for every incoming event.
sourceCodestringyes Long-TermThe source code of the parser. This is deprecated and will be replaced with script starting in version 1.142.
tagFields[string]yes Long-TermThe fields to use as tags. This is deprecated and will be replaced with fieldsToTag starting in version 1.142.
testCases[ParserTestCase]yes Long-TermTest cases that can be used to help verify that the parser works as expected. See ParserTestCase.
testData[string]yes Long-TermSaved test data (e.g., log lines) that you can use to test the parser. This is deprecated and will be replaced with testCases starting with version 1.142.
packagePackageInstallation  Long-TermThe package associated with the parser, if any. See PackageInstallation.
packageIdVersionedPackageSpecifier  Long-TermThe identifier of the package used, if one. VersionedPackageSpecifier is a scalar.
yamlTemplateyamlyes Long-TermA template that can be used to recreate the parser.