1. Packages
  2. Packages
  3. Newrelic Provider
  4. API Docs
  5. MetricPruningRule
Viewing docs for New Relic v5.69.0
published on Monday, May 25, 2026 by Pulumi
newrelic logo
Viewing docs for New Relic v5.69.0
published on Monday, May 25, 2026 by Pulumi

    Use this resource to create and manage metric pruning rules for a New Relic account.

    A metric pruning rule strips specific high-cardinality attributes from dimensional metric aggregates before they are stored. Unlike dropping a metric entirely, pruning keeps the metric signal intact while removing the nominated attributes — reducing cardinality without any loss of the metric itself.


    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const example = new newrelic.MetricPruningRule("example", {
        nrql: "SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'",
        description: "Remove collector.name attribute from http.server.duration to reduce cardinality",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    example = newrelic.MetricPruningRule("example",
        nrql="SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'",
        description="Remove collector.name attribute from http.server.duration to reduce cardinality")
    
    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.NewMetricPruningRule(ctx, "example", &newrelic.MetricPruningRuleArgs{
    			Nrql:        pulumi.String("SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'"),
    			Description: pulumi.String("Remove collector.name attribute from http.server.duration to reduce cardinality"),
    		})
    		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 example = new NewRelic.MetricPruningRule("example", new()
        {
            Nrql = "SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'",
            Description = "Remove collector.name attribute from http.server.duration to reduce cardinality",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.newrelic.MetricPruningRule;
    import com.pulumi.newrelic.MetricPruningRuleArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 example = new MetricPruningRule("example", MetricPruningRuleArgs.builder()
                .nrql("SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'")
                .description("Remove collector.name attribute from http.server.duration to reduce cardinality")
                .build());
    
        }
    }
    
    resources:
      example:
        type: newrelic:MetricPruningRule
        properties:
          nrql: SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'
          description: Remove collector.name attribute from http.server.duration to reduce cardinality
    
    pulumi {
      required_providers {
        newrelic = {
          source = "pulumi/newrelic"
        }
      }
    }
    
    resource "newrelic_metricpruningrule" "example" {
      nrql        = "SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'"
      description = "Remove collector.name attribute from http.server.duration to reduce cardinality"
    }
    

    With an explicit account ID

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    
    const example = new newrelic.MetricPruningRule("example", {
        accountId: "12345678",
        nrql: "SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'",
        description: "Remove collector.name attribute from http.server.duration to reduce cardinality",
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    example = newrelic.MetricPruningRule("example",
        account_id="12345678",
        nrql="SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'",
        description="Remove collector.name attribute from http.server.duration to reduce cardinality")
    
    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.NewMetricPruningRule(ctx, "example", &newrelic.MetricPruningRuleArgs{
    			AccountId:   pulumi.String("12345678"),
    			Nrql:        pulumi.String("SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'"),
    			Description: pulumi.String("Remove collector.name attribute from http.server.duration to reduce cardinality"),
    		})
    		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 example = new NewRelic.MetricPruningRule("example", new()
        {
            AccountId = "12345678",
            Nrql = "SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'",
            Description = "Remove collector.name attribute from http.server.duration to reduce cardinality",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.newrelic.MetricPruningRule;
    import com.pulumi.newrelic.MetricPruningRuleArgs;
    import java.util.ArrayList;
    import java.util.Arrays;
    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 example = new MetricPruningRule("example", MetricPruningRuleArgs.builder()
                .accountId("12345678")
                .nrql("SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'")
                .description("Remove collector.name attribute from http.server.duration to reduce cardinality")
                .build());
    
        }
    }
    
    resources:
      example:
        type: newrelic:MetricPruningRule
        properties:
          accountId: 1.2345678e+07
          nrql: SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'
          description: Remove collector.name attribute from http.server.duration to reduce cardinality
    
    pulumi {
      required_providers {
        newrelic = {
          source = "pulumi/newrelic"
        }
      }
    }
    
    resource "newrelic_metricpruningrule" "example" {
      account_id  = 12345678
      nrql        = "SELECT collector.name FROM Metric WHERE metricName = 'http.server.duration'"
      description = "Remove collector.name attribute from http.server.duration to reduce cardinality"
    }
    

    Create MetricPruningRule Resource

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

    Constructor syntax

    new MetricPruningRule(name: string, args: MetricPruningRuleArgs, opts?: CustomResourceOptions);
    @overload
    def MetricPruningRule(resource_name: str,
                          args: MetricPruningRuleArgs,
                          opts: Optional[ResourceOptions] = None)
    
    @overload
    def MetricPruningRule(resource_name: str,
                          opts: Optional[ResourceOptions] = None,
                          nrql: Optional[str] = None,
                          account_id: Optional[str] = None,
                          description: Optional[str] = None)
    func NewMetricPruningRule(ctx *Context, name string, args MetricPruningRuleArgs, opts ...ResourceOption) (*MetricPruningRule, error)
    public MetricPruningRule(string name, MetricPruningRuleArgs args, CustomResourceOptions? opts = null)
    public MetricPruningRule(String name, MetricPruningRuleArgs args)
    public MetricPruningRule(String name, MetricPruningRuleArgs args, CustomResourceOptions options)
    
    type: newrelic:MetricPruningRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "newrelic_metricpruningrule" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args MetricPruningRuleArgs
    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 MetricPruningRuleArgs
    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 MetricPruningRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args MetricPruningRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args MetricPruningRuleArgs
    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 metricPruningRuleResource = new NewRelic.MetricPruningRule("metricPruningRuleResource", new()
    {
        Nrql = "string",
        AccountId = "string",
        Description = "string",
    });
    
    example, err := newrelic.NewMetricPruningRule(ctx, "metricPruningRuleResource", &newrelic.MetricPruningRuleArgs{
    	Nrql:        pulumi.String("string"),
    	AccountId:   pulumi.String("string"),
    	Description: pulumi.String("string"),
    })
    
    resource "newrelic_metricpruningrule" "metricPruningRuleResource" {
      nrql        = "string"
      account_id  = "string"
      description = "string"
    }
    
    var metricPruningRuleResource = new MetricPruningRule("metricPruningRuleResource", MetricPruningRuleArgs.builder()
        .nrql("string")
        .accountId("string")
        .description("string")
        .build());
    
    metric_pruning_rule_resource = newrelic.MetricPruningRule("metricPruningRuleResource",
        nrql="string",
        account_id="string",
        description="string")
    
    const metricPruningRuleResource = new newrelic.MetricPruningRule("metricPruningRuleResource", {
        nrql: "string",
        accountId: "string",
        description: "string",
    });
    
    type: newrelic:MetricPruningRule
    properties:
        accountId: string
        description: string
        nrql: string
    

    MetricPruningRule 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 MetricPruningRule resource accepts the following input properties:

    Nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    AccountId string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    Description string
    A human-readable description of what this pruning rule does.
    Nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    AccountId string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    Description string
    A human-readable description of what this pruning rule does.
    nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    account_id string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description string
    A human-readable description of what this pruning rule does.
    nrql String
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    accountId String

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description String
    A human-readable description of what this pruning rule does.
    nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    accountId string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description string
    A human-readable description of what this pruning rule does.
    nrql str
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    account_id str

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description str
    A human-readable description of what this pruning rule does.
    nrql String
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    accountId String

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description String
    A human-readable description of what this pruning rule does.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    RuleId string
    The unique identifier of the pruning rule assigned by New Relic.
    Id string
    The provider-assigned unique ID for this managed resource.
    RuleId string
    The unique identifier of the pruning rule assigned by New Relic.
    id string
    The provider-assigned unique ID for this managed resource.
    rule_id string
    The unique identifier of the pruning rule assigned by New Relic.
    id String
    The provider-assigned unique ID for this managed resource.
    ruleId String
    The unique identifier of the pruning rule assigned by New Relic.
    id string
    The provider-assigned unique ID for this managed resource.
    ruleId string
    The unique identifier of the pruning rule assigned by New Relic.
    id str
    The provider-assigned unique ID for this managed resource.
    rule_id str
    The unique identifier of the pruning rule assigned by New Relic.
    id String
    The provider-assigned unique ID for this managed resource.
    ruleId String
    The unique identifier of the pruning rule assigned by New Relic.

    Look up Existing MetricPruningRule Resource

    Get an existing MetricPruningRule 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?: MetricPruningRuleState, opts?: CustomResourceOptions): MetricPruningRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_id: Optional[str] = None,
            description: Optional[str] = None,
            nrql: Optional[str] = None,
            rule_id: Optional[str] = None) -> MetricPruningRule
    func GetMetricPruningRule(ctx *Context, name string, id IDInput, state *MetricPruningRuleState, opts ...ResourceOption) (*MetricPruningRule, error)
    public static MetricPruningRule Get(string name, Input<string> id, MetricPruningRuleState? state, CustomResourceOptions? opts = null)
    public static MetricPruningRule get(String name, Output<String> id, MetricPruningRuleState state, CustomResourceOptions options)
    resources:  _:    type: newrelic:MetricPruningRule    get:      id: ${id}
    import {
      to = newrelic_metricpruningrule.example
      id = "${id}"
    }
    
    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 string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    Description string
    A human-readable description of what this pruning rule does.
    Nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    RuleId string
    The unique identifier of the pruning rule assigned by New Relic.
    AccountId string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    Description string
    A human-readable description of what this pruning rule does.
    Nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    RuleId string
    The unique identifier of the pruning rule assigned by New Relic.
    account_id string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description string
    A human-readable description of what this pruning rule does.
    nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    rule_id string
    The unique identifier of the pruning rule assigned by New Relic.
    accountId String

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description String
    A human-readable description of what this pruning rule does.
    nrql String
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    ruleId String
    The unique identifier of the pruning rule assigned by New Relic.
    accountId string

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description string
    A human-readable description of what this pruning rule does.
    nrql string
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    ruleId string
    The unique identifier of the pruning rule assigned by New Relic.
    account_id str

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description str
    A human-readable description of what this pruning rule does.
    nrql str
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    rule_id str
    The unique identifier of the pruning rule assigned by New Relic.
    accountId String

    The New Relic account ID in which to create the pruning rule. Defaults to the account ID configured on the provider.

    Note: All arguments on this resource are immutable. Any change to an existing newrelic.MetricPruningRule will cause the resource to be destroyed and recreated with the updated configuration.

    description String
    A human-readable description of what this pruning rule does.
    nrql String
    The NRQL query that identifies the metric and the specific attributes to prune. The SELECT clause must name the attributes to remove (not SELECT *), and the FROM clause must target Metric. Example: SELECT collector.name FROM Metric WHERE metricName = 'my.metric.name'.
    ruleId String
    The unique identifier of the pruning rule assigned by New Relic.

    Import

    Metric pruning rules can be imported using the composite ID format <account_id>:<rule_id>:

    $ pulumi import newrelic:index/metricPruningRule:MetricPruningRule example 12345678:1234
    

    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
    Viewing docs for New Relic v5.69.0
    published on Monday, May 25, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial