1. Packages
  2. Newrelic Provider
  3. API Docs
  4. LogParsingRule
New Relic v5.44.0 published on Saturday, Mar 29, 2025 by Pulumi

newrelic.LogParsingRule

Explore with Pulumi AI

Use this resource to create, update and delete New Relic Log Parsing Rule.

Example Usage

Use this example to create the log parse rule.

import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";

const foo = new newrelic.LogParsingRule("foo", {
    name: "log_parse_rule",
    attribute: "message",
    enabled: true,
    grok: "sampleattribute='%{NUMBER:test:int}'",
    lucene: "logtype:linux_messages",
    nrql: "SELECT * FROM Log WHERE logtype = 'linux_messages'",
});
Copy
import pulumi
import pulumi_newrelic as newrelic

foo = newrelic.LogParsingRule("foo",
    name="log_parse_rule",
    attribute="message",
    enabled=True,
    grok="sampleattribute='%{NUMBER:test:int}'",
    lucene="logtype:linux_messages",
    nrql="SELECT * FROM Log WHERE logtype = 'linux_messages'")
Copy
package main

import (
	"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := newrelic.NewLogParsingRule(ctx, "foo", &newrelic.LogParsingRuleArgs{
			Name:      pulumi.String("log_parse_rule"),
			Attribute: pulumi.String("message"),
			Enabled:   pulumi.Bool(true),
			Grok:      pulumi.String("sampleattribute='%{NUMBER:test:int}'"),
			Lucene:    pulumi.String("logtype:linux_messages"),
			Nrql:      pulumi.String("SELECT * FROM Log WHERE logtype = 'linux_messages'"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;

return await Deployment.RunAsync(() => 
{
    var foo = new NewRelic.LogParsingRule("foo", new()
    {
        Name = "log_parse_rule",
        Attribute = "message",
        Enabled = true,
        Grok = "sampleattribute='%{NUMBER:test:int}'",
        Lucene = "logtype:linux_messages",
        Nrql = "SELECT * FROM Log WHERE logtype = 'linux_messages'",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.LogParsingRule;
import com.pulumi.newrelic.LogParsingRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var foo = new LogParsingRule("foo", LogParsingRuleArgs.builder()
            .name("log_parse_rule")
            .attribute("message")
            .enabled(true)
            .grok("sampleattribute='%{NUMBER:test:int}'")
            .lucene("logtype:linux_messages")
            .nrql("SELECT * FROM Log WHERE logtype = 'linux_messages'")
            .build());

    }
}
Copy
resources:
  foo:
    type: newrelic:LogParsingRule
    properties:
      name: log_parse_rule
      attribute: message
      enabled: true
      grok: sampleattribute='%{NUMBER:test:int}'
      lucene: logtype:linux_messages
      nrql: SELECT * FROM Log WHERE logtype = 'linux_messages'
Copy

Additional Example

Use this example to validate a grok pattern and create the log parse rule. More information on grok pattern can be found here

import * as pulumi from "@pulumi/pulumi";
import * as newrelic from "@pulumi/newrelic";

const grok = newrelic.getTestGrokPattern({
    grok: "%{IP:host_ip}",
    logLines: ["host_ip: 43.3.120.2"],
});
const foo = new newrelic.LogParsingRule("foo", {
    name: "log_parse_rule",
    attribute: "message",
    enabled: true,
    grok: grok.then(grok => grok.grok),
    lucene: "logtype:linux_messages",
    nrql: "SELECT * FROM Log WHERE logtype = 'linux_messages'",
    matched: grok.then(grok => grok.testGroks?.[0]?.matched),
});
Copy
import pulumi
import pulumi_newrelic as newrelic

grok = newrelic.get_test_grok_pattern(grok="%{IP:host_ip}",
    log_lines=["host_ip: 43.3.120.2"])
foo = newrelic.LogParsingRule("foo",
    name="log_parse_rule",
    attribute="message",
    enabled=True,
    grok=grok.grok,
    lucene="logtype:linux_messages",
    nrql="SELECT * FROM Log WHERE logtype = 'linux_messages'",
    matched=grok.test_groks[0].matched)
Copy
package main

import (
	"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		grok, err := newrelic.GetTestGrokPattern(ctx, &newrelic.GetTestGrokPatternArgs{
			Grok: "%{IP:host_ip}",
			LogLines: []string{
				"host_ip: 43.3.120.2",
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = newrelic.NewLogParsingRule(ctx, "foo", &newrelic.LogParsingRuleArgs{
			Name:      pulumi.String("log_parse_rule"),
			Attribute: pulumi.String("message"),
			Enabled:   pulumi.Bool(true),
			Grok:      pulumi.String(grok.Grok),
			Lucene:    pulumi.String("logtype:linux_messages"),
			Nrql:      pulumi.String("SELECT * FROM Log WHERE logtype = 'linux_messages'"),
			Matched:   pulumi.Bool(grok.TestGroks[0].Matched),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using NewRelic = Pulumi.NewRelic;

return await Deployment.RunAsync(() => 
{
    var grok = NewRelic.GetTestGrokPattern.Invoke(new()
    {
        Grok = "%{IP:host_ip}",
        LogLines = new[]
        {
            "host_ip: 43.3.120.2",
        },
    });

    var foo = new NewRelic.LogParsingRule("foo", new()
    {
        Name = "log_parse_rule",
        Attribute = "message",
        Enabled = true,
        Grok = grok.Apply(getTestGrokPatternResult => getTestGrokPatternResult.Grok),
        Lucene = "logtype:linux_messages",
        Nrql = "SELECT * FROM Log WHERE logtype = 'linux_messages'",
        Matched = grok.Apply(getTestGrokPatternResult => getTestGrokPatternResult.TestGroks[0]?.Matched),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.newrelic.NewrelicFunctions;
import com.pulumi.newrelic.inputs.GetTestGrokPatternArgs;
import com.pulumi.newrelic.LogParsingRule;
import com.pulumi.newrelic.LogParsingRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var grok = NewrelicFunctions.getTestGrokPattern(GetTestGrokPatternArgs.builder()
            .grok("%{IP:host_ip}")
            .logLines("host_ip: 43.3.120.2")
            .build());

        var foo = new LogParsingRule("foo", LogParsingRuleArgs.builder()
            .name("log_parse_rule")
            .attribute("message")
            .enabled(true)
            .grok(grok.applyValue(getTestGrokPatternResult -> getTestGrokPatternResult.grok()))
            .lucene("logtype:linux_messages")
            .nrql("SELECT * FROM Log WHERE logtype = 'linux_messages'")
            .matched(grok.applyValue(getTestGrokPatternResult -> getTestGrokPatternResult.testGroks()[0].matched()))
            .build());

    }
}
Copy
resources:
  foo:
    type: newrelic:LogParsingRule
    properties:
      name: log_parse_rule
      attribute: message
      enabled: true
      grok: ${grok.grok}
      lucene: logtype:linux_messages
      nrql: SELECT * FROM Log WHERE logtype = 'linux_messages'
      matched: ${grok.testGroks[0].matched}
variables:
  grok:
    fn::invoke:
      function: newrelic:getTestGrokPattern
      arguments:
        grok: '%{IP:host_ip}'
        logLines:
          - 'host_ip: 43.3.120.2'
Copy

Create LogParsingRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new LogParsingRule(name: string, args: LogParsingRuleArgs, opts?: CustomResourceOptions);
@overload
def LogParsingRule(resource_name: str,
                   args: LogParsingRuleArgs,
                   opts: Optional[ResourceOptions] = None)

@overload
def LogParsingRule(resource_name: str,
                   opts: Optional[ResourceOptions] = None,
                   enabled: Optional[bool] = None,
                   grok: Optional[str] = None,
                   lucene: Optional[str] = None,
                   nrql: Optional[str] = None,
                   account_id: Optional[str] = None,
                   attribute: Optional[str] = None,
                   matched: Optional[bool] = None,
                   name: Optional[str] = None)
func NewLogParsingRule(ctx *Context, name string, args LogParsingRuleArgs, opts ...ResourceOption) (*LogParsingRule, error)
public LogParsingRule(string name, LogParsingRuleArgs args, CustomResourceOptions? opts = null)
public LogParsingRule(String name, LogParsingRuleArgs args)
public LogParsingRule(String name, LogParsingRuleArgs args, CustomResourceOptions options)
type: newrelic:LogParsingRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. LogParsingRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. LogParsingRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. LogParsingRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. LogParsingRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. LogParsingRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var logParsingRuleResource = new NewRelic.LogParsingRule("logParsingRuleResource", new()
{
    Enabled = false,
    Grok = "string",
    Lucene = "string",
    Nrql = "string",
    AccountId = "string",
    Attribute = "string",
    Matched = false,
    Name = "string",
});
Copy
example, err := newrelic.NewLogParsingRule(ctx, "logParsingRuleResource", &newrelic.LogParsingRuleArgs{
	Enabled:   pulumi.Bool(false),
	Grok:      pulumi.String("string"),
	Lucene:    pulumi.String("string"),
	Nrql:      pulumi.String("string"),
	AccountId: pulumi.String("string"),
	Attribute: pulumi.String("string"),
	Matched:   pulumi.Bool(false),
	Name:      pulumi.String("string"),
})
Copy
var logParsingRuleResource = new LogParsingRule("logParsingRuleResource", LogParsingRuleArgs.builder()
    .enabled(false)
    .grok("string")
    .lucene("string")
    .nrql("string")
    .accountId("string")
    .attribute("string")
    .matched(false)
    .name("string")
    .build());
Copy
log_parsing_rule_resource = newrelic.LogParsingRule("logParsingRuleResource",
    enabled=False,
    grok="string",
    lucene="string",
    nrql="string",
    account_id="string",
    attribute="string",
    matched=False,
    name="string")
Copy
const logParsingRuleResource = new newrelic.LogParsingRule("logParsingRuleResource", {
    enabled: false,
    grok: "string",
    lucene: "string",
    nrql: "string",
    accountId: "string",
    attribute: "string",
    matched: false,
    name: "string",
});
Copy
type: newrelic:LogParsingRule
properties:
    accountId: string
    attribute: string
    enabled: false
    grok: string
    lucene: string
    matched: false
    name: string
    nrql: string
Copy

LogParsingRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The LogParsingRule resource accepts the following input properties:

Enabled This property is required. bool
Whether the rule should be applied or not to incoming data.
Grok This property is required. string
The Grok of what to parse.
Lucene This property is required. string
The Lucene to match events to the parsing rule.
Nrql This property is required. string
The NRQL to match events to the parsing rule.
AccountId string
The account id associated with the obfuscation rule.
Attribute string
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
Matched bool
Whether the Grok pattern matched.
Name string
Name of rule.
Enabled This property is required. bool
Whether the rule should be applied or not to incoming data.
Grok This property is required. string
The Grok of what to parse.
Lucene This property is required. string
The Lucene to match events to the parsing rule.
Nrql This property is required. string
The NRQL to match events to the parsing rule.
AccountId string
The account id associated with the obfuscation rule.
Attribute string
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
Matched bool
Whether the Grok pattern matched.
Name string
Name of rule.
enabled This property is required. Boolean
Whether the rule should be applied or not to incoming data.
grok This property is required. String
The Grok of what to parse.
lucene This property is required. String
The Lucene to match events to the parsing rule.
nrql This property is required. String
The NRQL to match events to the parsing rule.
accountId String
The account id associated with the obfuscation rule.
attribute String
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
matched Boolean
Whether the Grok pattern matched.
name String
Name of rule.
enabled This property is required. boolean
Whether the rule should be applied or not to incoming data.
grok This property is required. string
The Grok of what to parse.
lucene This property is required. string
The Lucene to match events to the parsing rule.
nrql This property is required. string
The NRQL to match events to the parsing rule.
accountId string
The account id associated with the obfuscation rule.
attribute string
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
matched boolean
Whether the Grok pattern matched.
name string
Name of rule.
enabled This property is required. bool
Whether the rule should be applied or not to incoming data.
grok This property is required. str
The Grok of what to parse.
lucene This property is required. str
The Lucene to match events to the parsing rule.
nrql This property is required. str
The NRQL to match events to the parsing rule.
account_id str
The account id associated with the obfuscation rule.
attribute str
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
matched bool
Whether the Grok pattern matched.
name str
Name of rule.
enabled This property is required. Boolean
Whether the rule should be applied or not to incoming data.
grok This property is required. String
The Grok of what to parse.
lucene This property is required. String
The Lucene to match events to the parsing rule.
nrql This property is required. String
The NRQL to match events to the parsing rule.
accountId String
The account id associated with the obfuscation rule.
attribute String
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
matched Boolean
Whether the Grok pattern matched.
name String
Name of rule.

Outputs

All input properties are implicitly available as output properties. Additionally, the LogParsingRule resource produces the following output properties:

Deleted bool
Whether or not this rule is deleted.
Id string
The provider-assigned unique ID for this managed resource.
Deleted bool
Whether or not this rule is deleted.
Id string
The provider-assigned unique ID for this managed resource.
deleted Boolean
Whether or not this rule is deleted.
id String
The provider-assigned unique ID for this managed resource.
deleted boolean
Whether or not this rule is deleted.
id string
The provider-assigned unique ID for this managed resource.
deleted bool
Whether or not this rule is deleted.
id str
The provider-assigned unique ID for this managed resource.
deleted Boolean
Whether or not this rule is deleted.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing LogParsingRule Resource

Get an existing LogParsingRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: LogParsingRuleState, opts?: CustomResourceOptions): LogParsingRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        account_id: Optional[str] = None,
        attribute: Optional[str] = None,
        deleted: Optional[bool] = None,
        enabled: Optional[bool] = None,
        grok: Optional[str] = None,
        lucene: Optional[str] = None,
        matched: Optional[bool] = None,
        name: Optional[str] = None,
        nrql: Optional[str] = None) -> LogParsingRule
func GetLogParsingRule(ctx *Context, name string, id IDInput, state *LogParsingRuleState, opts ...ResourceOption) (*LogParsingRule, error)
public static LogParsingRule Get(string name, Input<string> id, LogParsingRuleState? state, CustomResourceOptions? opts = null)
public static LogParsingRule get(String name, Output<String> id, LogParsingRuleState state, CustomResourceOptions options)
resources:  _:    type: newrelic:LogParsingRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
AccountId string
The account id associated with the obfuscation rule.
Attribute string
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
Deleted bool
Whether or not this rule is deleted.
Enabled bool
Whether the rule should be applied or not to incoming data.
Grok string
The Grok of what to parse.
Lucene string
The Lucene to match events to the parsing rule.
Matched bool
Whether the Grok pattern matched.
Name string
Name of rule.
Nrql string
The NRQL to match events to the parsing rule.
AccountId string
The account id associated with the obfuscation rule.
Attribute string
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
Deleted bool
Whether or not this rule is deleted.
Enabled bool
Whether the rule should be applied or not to incoming data.
Grok string
The Grok of what to parse.
Lucene string
The Lucene to match events to the parsing rule.
Matched bool
Whether the Grok pattern matched.
Name string
Name of rule.
Nrql string
The NRQL to match events to the parsing rule.
accountId String
The account id associated with the obfuscation rule.
attribute String
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
deleted Boolean
Whether or not this rule is deleted.
enabled Boolean
Whether the rule should be applied or not to incoming data.
grok String
The Grok of what to parse.
lucene String
The Lucene to match events to the parsing rule.
matched Boolean
Whether the Grok pattern matched.
name String
Name of rule.
nrql String
The NRQL to match events to the parsing rule.
accountId string
The account id associated with the obfuscation rule.
attribute string
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
deleted boolean
Whether or not this rule is deleted.
enabled boolean
Whether the rule should be applied or not to incoming data.
grok string
The Grok of what to parse.
lucene string
The Lucene to match events to the parsing rule.
matched boolean
Whether the Grok pattern matched.
name string
Name of rule.
nrql string
The NRQL to match events to the parsing rule.
account_id str
The account id associated with the obfuscation rule.
attribute str
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
deleted bool
Whether or not this rule is deleted.
enabled bool
Whether the rule should be applied or not to incoming data.
grok str
The Grok of what to parse.
lucene str
The Lucene to match events to the parsing rule.
matched bool
Whether the Grok pattern matched.
name str
Name of rule.
nrql str
The NRQL to match events to the parsing rule.
accountId String
The account id associated with the obfuscation rule.
attribute String
The parsing rule will apply to value of this attribute. If field is not provided, value will default to message.
deleted Boolean
Whether or not this rule is deleted.
enabled Boolean
Whether the rule should be applied or not to incoming data.
grok String
The Grok of what to parse.
lucene String
The Lucene to match events to the parsing rule.
matched Boolean
Whether the Grok pattern matched.
name String
Name of rule.
nrql String
The NRQL to match events to the parsing rule.

Import

New Relic log parsing rule can be imported using the rule ID, e.g.

bash

$ pulumi import newrelic:index/logParsingRule:LogParsingRule foo 3456789
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
New Relic pulumi/pulumi-newrelic
License
Apache-2.0
Notes
This Pulumi package is based on the newrelic Terraform Provider.