import * as pulumi from "@pulumi/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. * * > **Migrating from `newrelic.NrqlDropRule`?** If you are migrating [`newrelic.NrqlDropRule`](https://www.terraform.io/providers/newrelic/newrelic/latest/docs/resources/nrql_drop_rule) resources with `action = "dropAttributesFromMetricAggregates"`, `newrelic.MetricPruningRule` is the recommended replacement. Please refer to the [Drop Rules EOL Migration Guide](https://www.terraform.io/providers/newrelic/newrelic/latest/docs/guides/drop_rules_eol_guide) for more details. * * *** * * ## Example Usage * * ```typescript * 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", * }); * ``` * * ### With an explicit account ID * * ```typescript * 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", * }); * ``` * * ### 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. * * ```typescript * 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`, * })); * } * } * ``` * * 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. * * *** * * ## Import * * Metric pruning rules can be imported using the composite ID format `:`: * * ```sh * $ pulumi import newrelic:index/metricPruningRule:MetricPruningRule example 12345678:1234 * ``` */ export declare class MetricPruningRule extends pulumi.CustomResource { /** * Get an existing MetricPruningRule resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: MetricPruningRuleState, opts?: pulumi.CustomResourceOptions): MetricPruningRule; /** * Returns true if the given object is an instance of MetricPruningRule. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is MetricPruningRule; /** * 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. */ readonly accountId: pulumi.Output; /** * A human-readable description of what this pruning rule does. */ readonly description: pulumi.Output; /** * 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'`. */ readonly nrql: pulumi.Output; /** * The unique identifier of the pruning rule assigned by New Relic. */ readonly ruleId: pulumi.Output; /** * Create a MetricPruningRule resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: MetricPruningRuleArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering MetricPruningRule resources. */ export interface MetricPruningRuleState { /** * 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. */ accountId?: pulumi.Input; /** * A human-readable description of what this pruning rule does. */ description?: pulumi.Input; /** * 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'`. */ nrql?: pulumi.Input; /** * The unique identifier of the pruning rule assigned by New Relic. */ ruleId?: pulumi.Input; } /** * The set of arguments for constructing a MetricPruningRule resource. */ export interface MetricPruningRuleArgs { /** * 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. */ accountId?: pulumi.Input; /** * A human-readable description of what this pruning rule does. */ description?: pulumi.Input; /** * 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'`. */ nrql: pulumi.Input; } //# sourceMappingURL=metricPruningRule.d.ts.map