The createParserFromPackageTemplate() GraphQL mutation field may be used to create a parser from a package parser template.

Similar to this mutation, there is the createParserFromTemplate() for creating one from a template and cloneParser() for copying an existing one. There is also createParserV2() for making one from scratch.

Related to these mutations, there are updateParserV2() and updateParserFromTemplate() for updating parsers. There's also testParserV2() to test a parser and deleteParserV2() to delete one.

Hide Query Example

Show Parsers Query

For more information on creating a parser, see the Custom Parsers documentation page. You may also want to look at the Parse Data and Package Management pages for related information.

API Stability Long-Term

Syntax

graphql
createParserFromPackageTemplate(
      viewName: string!
      packageId: VersionedPackageSpecifier!
      parserTemplateName: string!
      overrideName: string
   ): CreateParserFromPackageTemplateMutation!

For the input datatype, you'll have to give the the package name, followed by an ampersand and then the version number (see Example above). You'll also have to give the name of the template contained in the package. See the Given Datatype section.

For the results, you can get the event fields that will be removed from events, a template for recreating the parser, and other information. See the Returned Datatype section for more.

Example

Raw
graphql
mutation {
  createParserFromPackageTemplate(
        viewName: "humio",
        packageId: "humio/insights@0.0.14",
        parserTemplateName: "humio",
        overrideName: "my-basic-parser"
      )
  { parser { id, fieldsToTag } }
}
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 {
  createParserFromPackageTemplate(
        viewName: \"humio\",
        packageId: \"humio/insights@0.0.14\",
        parserTemplateName: \"humio\",
        overrideName: \"my-basic-parser\"
      )
  { parser { id, fieldsToTag } }
}"
}
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 {
  createParserFromPackageTemplate(
        viewName: \"humio\",
        packageId: \"humio/insights@0.0.14\",
        parserTemplateName: \"humio\",
        overrideName: \"my-basic-parser\"
      )
  { parser { id, fieldsToTag } }
}"
}
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 { ^
  createParserFromPackageTemplate( ^
        viewName: \"humio\", ^
        packageId: \"humio/insights@0.0.14\", ^
        parserTemplateName: \"humio\", ^
        overrideName: \"my-basic-parser\" ^
      ) ^
  { parser { id, fieldsToTag } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createParserFromPackageTemplate(
        viewName: \"humio\",
        packageId: \"humio/insights@0.0.14\",
        parserTemplateName: \"humio\",
        overrideName: \"my-basic-parser\"
      )
  { parser { id, fieldsToTag } }
}"
}'
    "$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 = "mutation {
  createParserFromPackageTemplate(
        viewName: \"humio\",
        packageId: \"humio/insights@0.0.14\",
        parserTemplateName: \"humio\",
        overrideName: \"my-basic-parser\"
      )
  { parser { id, fieldsToTag } }
}";
$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" : "mutation {
  createParserFromPackageTemplate(
        viewName: \"humio\",
        packageId: \"humio/insights@0.0.14\",
        parserTemplateName: \"humio\",
        overrideName: \"my-basic-parser\"
      )
  { parser { id, fieldsToTag } }
}"
}'''

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 {
  createParserFromPackageTemplate(
        viewName: \"humio\",
        packageId: \"humio/insights@0.0.14\",
        parserTemplateName: \"humio\",
        overrideName: \"my-basic-parser\"
      )
  { parser { id, fieldsToTag } }
}"
}
);


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

Given Datatype

For the input datatype, you'll have to give the the package name, followed by an ampersand and then the version number (see Example above). You'll also have to give the name of the template contained in the package. See the table below for more details:

Table: Input Using Standard Datatypes

Parameter Type Required Default Description
overrideName string     The name of the new parser to create.
packageId VersionedPackageSpecifier yes   The identifier of the package containing the parser template. VersionedPackageSpecifier is a scalar.
parserTemplateName string yes   The name of the parser template in the package.
viewName string yes   The name of the view where the package is installed.

Returned Datatype

With this returned datatype, through sub-parameters, you can get the fields that will be removed from events, a template for recreating the parser, and other information. What is available is listed in the table here:

Table: CreateParserFromPackageTemplateMutation

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For return datatypes, this indicates that you must specify which fields you want returned in the results.
Table last updated: Sep 24, 2024
parserParseryes Long-TermThe parser to create from the package template. See Parser.

The datatype above uses a core datatype for getting parser information. For your convenience, the table for that sub-datatype is included here:

Table: Parser

ParameterTypeRequiredDefaultStabilityDescription
Some arguments may be required, as indicated in the Required column. For return datatypes, this indicates that you must specify which fields you want returned in the results.
Table last updated: Sep 30, 2025
createdInfoAssetCommitMetadata  Long-TermMetadata related to the creation of the parser. See AssetCommitMetadata.
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.
isOverriddenbooleanyes PreviewTrue if the parser is one of LogScale's built-in parsers, and it is overridden by a custom parser.
languageVersionLanguageVersionyes Long-TermThe language version used by the parser. See LanguageVersion.
modifiedInfoAssetCommitMetadata  Long-TermMetadata related to the latest modification of the parser. See AssetCommitMetadata.
namestringyes Long-TermThe name of the parser.
originDisplayStringstringyes PreviewThe origin of a parser. Can either be "Built in", "Local" or a package.
overridesBuiltInParserbooleanyes PreviewTrue if the parser is overrides one of LogScale's built-in parsers.
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.
scriptstringyes Long-TermThe parser script that is executed for every incoming event.
testCases[ParserTestCase]yes Long-TermTest cases that can be used to help verify that the parser works as expected. See ParserTestCase.
yamlTemplateYAMLyes Long-TermA template that can be used to recreate the parser. YAML is a scalar.