1. Packages
  2. Packages
  3. Newrelic Provider
  4. API Docs
  5. MetricPruningRule
Viewing docs for New Relic v5.72.1
published on Wednesday, Jun 17, 2026 by Pulumi
newrelic logo
Viewing docs for New Relic v5.72.1
published on Wednesday, Jun 17, 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"
    }
    

    Pruning the same attribute from many metrics in bulk

    When the same attribute needs to be stripped from a set of metrics, keep the metric list in locals and use forEach with a templated nrql and description. Only the metric name varies between rules — the rest of the configuration is shared.

    import * as pulumi from "@pulumi/pulumi";
    import * as newrelic from "@pulumi/newrelic";
    import * as std from "@pulumi/std";
    
    export = async () => {
        // The attribute to prune from every metric in the list below.
        const prunedAttribute = "collector.name";
        // Metrics to apply the pruning rule to.
        // Add or remove entries here to manage rules in bulk.
        const metricsToPrune = (await std.toset({
            input: [
                "http.server.duration",
                "http.client.duration",
                "rpc.server.duration",
                "k8s.pod.cpu.usage",
                "k8s.pod.memory.usage",
            ],
        })).result;
        const bulk: newrelic.MetricPruningRule[] = [];
        for (const range of metricsToPrune.map((v, k) => ({key: k, value: v}))) {
            bulk.push(new newrelic.MetricPruningRule(`bulk-${range.key}`, {
                nrql: `SELECT ${prunedAttribute} FROM Metric WHERE metricName = '${range.value}'`,
                description: `Remove ${prunedAttribute} from ${range.value} to reduce cardinality`,
            }));
        }
    }
    
    import pulumi
    from typing import Any
    import pulumi_newrelic as newrelic
    import pulumi_std as std
    
    # The attribute to prune from every metric in the list below.
    pruned_attribute = "collector.name"
    # Metrics to apply the pruning rule to.
    # Add or remove entries here to manage rules in bulk.
    metrics_to_prune = std.toset(input=[
        "http.server.duration",
        "http.client.duration",
        "rpc.server.duration",
        "k8s.pod.cpu.usage",
        "k8s.pod.memory.usage",
    ]).result
    bulk: list[Any] = []
    for range in [{"key": k, "value": v} for [k, v] in enumerate(metrics_to_prune)]:
        bulk.append(newrelic.MetricPruningRule(f"bulk-{range['key']}",
            nrql=f"SELECT {pruned_attribute} FROM Metric WHERE metricName = '{range['value']}'",
            description=f"Remove {pruned_attribute} from {range['value']} to reduce cardinality"))
    
    package main
    
    import (
    	"fmt"
    
    	"github.com/pulumi/pulumi-newrelic/sdk/v5/go/newrelic"
    	"github.com/pulumi/pulumi-std/sdk/go/std"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// The attribute to prune from every metric in the list below.
    		prunedAttribute := "collector.name"
    		// Metrics to apply the pruning rule to.
    		// Add or remove entries here to manage rules in bulk.
    		metricsToPrune := std.Toset(ctx, &std.TosetArgs{
    			Input: []string{
    				"http.server.duration",
    				"http.client.duration",
    				"rpc.server.duration",
    				"k8s.pod.cpu.usage",
    				"k8s.pod.memory.usage",
    			},
    		}, nil).Result
    		var bulk []*newrelic.MetricPruningRule
    		for key0, val0 := range metricsToPrune {
    			__res, err := newrelic.NewMetricPruningRule(ctx, fmt.Sprintf("bulk-%v", key0), &newrelic.MetricPruningRuleArgs{
    				Nrql:        pulumi.Sprintf("SELECT %v FROM Metric WHERE metricName = '%v'", prunedAttribute, val0),
    				Description: pulumi.Sprintf("Remove %v from %v to reduce cardinality", prunedAttribute, val0),
    			})
    			if err != nil {
    				return err
    			}
    			bulk = append(bulk, __res)
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Pulumi;
    using NewRelic = Pulumi.NewRelic;
    using Std = Pulumi.Std;
    
    return await Deployment.RunAsync(async() => 
    {
        // The attribute to prune from every metric in the list below.
        var prunedAttribute = "collector.name";
    
        // Metrics to apply the pruning rule to.
        // Add or remove entries here to manage rules in bulk.
        var metricsToPrune = (await Std.Toset.InvokeAsync(new()
        {
            Input = new[]
            {
                "http.server.duration",
                "http.client.duration",
                "rpc.server.duration",
                "k8s.pod.cpu.usage",
                "k8s.pod.memory.usage",
            },
        })).Result;
    
        var bulk = new List<NewRelic.MetricPruningRule>();
        foreach (var range in )
        {
            bulk.Add(new NewRelic.MetricPruningRule($"bulk-{range.Key}", new()
            {
                Nrql = $"SELECT {prunedAttribute} FROM Metric WHERE metricName = '{range.Value}'",
                Description = $"Remove {prunedAttribute} from {range.Value} to reduce cardinality",
            }));
        }
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.std.StdFunctions;
    import com.pulumi.std.inputs.TosetArgs;
    import com.pulumi.newrelic.MetricPruningRule;
    import com.pulumi.newrelic.MetricPruningRuleArgs;
    import com.pulumi.codegen.internal.KeyedValue;
    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) {
            // The attribute to prune from every metric in the list below.
            final var prunedAttribute = "collector.name";
    
            // Metrics to apply the pruning rule to.
            // Add or remove entries here to manage rules in bulk.
            final var metricsToPrune = StdFunctions.toset(TosetArgs.builder()
                .input(            
                    "http.server.duration",
                    "http.client.duration",
                    "rpc.server.duration",
                    "k8s.pod.cpu.usage",
                    "k8s.pod.memory.usage")
                .build()).result();
    
            for (var range : KeyedValue.of(metricsToPrune)) {
                new MetricPruningRule("bulk-" + range.key(), MetricPruningRuleArgs.builder()
                    .nrql(String.format("SELECT %s FROM Metric WHERE metricName = '%s'", prunedAttribute,range.value()))
                    .description(String.format("Remove %s from %s to reduce cardinality", prunedAttribute,range.value()))
                    .build());
            }
    
        }
    }
    
    resources:
      bulk:
        type: newrelic:MetricPruningRule
        properties:
          nrql: SELECT ${prunedAttribute} FROM Metric WHERE metricName = '${range.value}'
          description: Remove ${prunedAttribute} from ${range.value} to reduce cardinality
        options: {}
    variables:
      # The attribute to prune from every metric in the list below.
      prunedAttribute: collector.name
      # Metrics to apply the pruning rule to.
      # Add or remove entries here to manage rules in bulk.
      metricsToPrune:
        fn::invoke:
          function: std:toset
          arguments:
            input:
              - http.server.duration
              - http.client.duration
              - rpc.server.duration
              - k8s.pod.cpu.usage
              - k8s.pod.memory.usage
          return: result
    
    pulumi {
      required_providers {
        newrelic = {
          source = "pulumi/newrelic"
        }
        std = {
          source = "pulumi/std"
        }
      }
    }
    
    resource "newrelic_metricpruningrule" "bulk" {
      for_each    = local.metricsToPrune
      nrql        ="SELECT ${local.prunedAttribute} FROM Metric WHERE metricName = '${each.value}'"
      description ="Remove ${local.prunedAttribute} from ${each.value} to reduce cardinality"
    }
    # The attribute to prune from every metric in the list below.
    locals {
      prunedAttribute = "collector.name"
    }
    # Metrics to apply the pruning rule to.
    # Add or remove entries here to manage rules in bulk.
    locals {
      metricsToPrune = toset(["http.server.duration", "http.client.duration", "rpc.server.duration", "k8s.pod.cpu.usage", "k8s.pod.memory.usage"])
    }
    

    Each entry in metricsToPrune produces an independent newrelic.MetricPruningRule resource (e.g. newrelic_metric_pruning_rule.bulk["http.server.duration"]) that can be inspected, imported, or destroyed individually.


    Behaviour

    • pulumi up — creates the pruning rule in New Relic. The rule begins stripping the nominated attributes from matching metric aggregates immediately after creation.
    • pulumi preview / terraform refresh on an existing resource — reads the current state of the pruning rule from New Relic and surfaces any drift (e.g. if the rule was deleted outside of Terraform).
    • terraform destroy — permanently deletes the pruning rule. Once removed, the nominated attributes will no longer be stripped from incoming metric data. There is no reset to a default state; the rule is deleted outright.

    Note: Because all arguments are immutable, any in-place change (e.g. updating the NRQL or description) will trigger a destroy-and-recreate. The old rule is deleted before the new one is created, so there will be a brief window during which no pruning is active for the affected metric.


    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.72.1
    published on Wednesday, Jun 17, 2026 by Pulumi

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial