1. Packages
  2. New Relic
  3. API Docs
  4. LogParsingRule
New Relic v5.23.0 published on Wednesday, Apr 24, 2024 by Pulumi

newrelic.LogParsingRule

Explore with Pulumi AI

newrelic logo
New Relic v5.23.0 published on Wednesday, Apr 24, 2024 by Pulumi

    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'",
    });
    
    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'")
    
    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
    	})
    }
    
    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'",
        });
    
    });
    
    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());
    
        }
    }
    
    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'
    

    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),
    });
    
    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)
    
    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
    	})
    }
    
    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),
        });
    
    });
    
    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());
    
        }
    }
    
    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'
    

    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[int] = 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 string
    The unique name of the resource.
    args LogParsingRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args LogParsingRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args LogParsingRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args LogParsingRuleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    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 = 0,
        Attribute = "string",
        Matched = false,
        Name = "string",
    });
    
    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.Int(0),
    	Attribute: pulumi.String("string"),
    	Matched:   pulumi.Bool(false),
    	Name:      pulumi.String("string"),
    })
    
    var logParsingRuleResource = new LogParsingRule("logParsingRuleResource", LogParsingRuleArgs.builder()        
        .enabled(false)
        .grok("string")
        .lucene("string")
        .nrql("string")
        .accountId(0)
        .attribute("string")
        .matched(false)
        .name("string")
        .build());
    
    log_parsing_rule_resource = newrelic.LogParsingRule("logParsingRuleResource",
        enabled=False,
        grok="string",
        lucene="string",
        nrql="string",
        account_id=0,
        attribute="string",
        matched=False,
        name="string")
    
    const logParsingRuleResource = new newrelic.LogParsingRule("logParsingRuleResource", {
        enabled: false,
        grok: "string",
        lucene: "string",
        nrql: "string",
        accountId: 0,
        attribute: "string",
        matched: false,
        name: "string",
    });
    
    type: newrelic:LogParsingRule
    properties:
        accountId: 0
        attribute: string
        enabled: false
        grok: string
        lucene: string
        matched: false
        name: string
        nrql: string
    

    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

    The LogParsingRule resource accepts the following input properties:

    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.
    Nrql string
    The NRQL to match events to the parsing rule.
    AccountId int
    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 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.
    Nrql string
    The NRQL to match events to the parsing rule.
    AccountId int
    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 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.
    nrql String
    The NRQL to match events to the parsing rule.
    accountId Integer
    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 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.
    nrql string
    The NRQL to match events to the parsing rule.
    accountId number
    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 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.
    nrql str
    The NRQL to match events to the parsing rule.
    account_id int
    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 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.
    nrql String
    The NRQL to match events to the parsing rule.
    accountId Number
    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[int] = 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 int
    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 int
    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 Integer
    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 number
    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 int
    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 Number
    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
    

    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.
    newrelic logo
    New Relic v5.23.0 published on Wednesday, Apr 24, 2024 by Pulumi