import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * Use this resource to create, update, and delete [New Relic Scorecard Rules](https://docs.newrelic.com/docs/service-architecture-intelligence/scorecards/getting-started/). * * A Scorecard Rule is a NRQL-based check that evaluates a binary score (0 = fail, 1 = pass) for each entity in your account on a recurring schedule. Rules are **independent entities** — they exist outside any scorecard and are attached to a `newrelic.Scorecard` via that scorecard's `ruleIds` attribute. * * > **CONSTRAINT: One rule per scorecard.** Each rule can only belong to **one scorecard at a time**. The New Relic API enforces this at the collection level. If you attempt to attach a rule that is already assigned to another scorecard, the apply will fail. To reassign a rule: remove its GUID from the current scorecard's `ruleIds`, apply that change, then add it to the new scorecard. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const alertCoverage = new newrelic.ScorecardRule("alert_coverage", { * name: "APM alert coverage", * description: "All APM services must have alerts configured", * enabled: true, * runInterval: 1440, * nrqlEngine: { * accounts: [accountId], * query: "SELECT if(latest(alertSeverity) != 'NOT_CONFIGURED', 1, 0) AS 'score' FROM Entity WHERE type = 'APM-APPLICATION' FACET id LIMIT MAX SINCE 1 day ago", * }, * tags: [{ * key: "team", * values: ["platform"], * }], * }); * ``` * * See additional examples below. * * ## Progress Level Relationship * * The `progressLevel` field links a rule to a tier in the parent scorecard's `progressLevels` block. The value must exactly match one of those tier IDs. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const alertConfigured = new newrelic.ScorecardRule("alert_configured", { * name: "Alerts configured", * enabled: true, * runInterval: 1440, * progressLevel: "foundation", * nrqlEngine: { * accounts: [accountId], * query: "SELECT if(latest(alertSeverity) != 'NOT_CONFIGURED', 1, 0) AS 'score' FROM Entity WHERE type = 'APM-APPLICATION' FACET id LIMIT MAX SINCE 1 day ago", * }, * }); * const lowLatency = new newrelic.ScorecardRule("low_latency", { * name: "P95 latency below 500ms", * enabled: true, * runInterval: 60, * progressLevel: "excellence", * nrqlEngine: { * accounts: [accountId], * query: "SELECT if(percentile(duration, 95) < 0.5, 1, 0) AS 'score' FROM Transaction FACET entity.guid LIMIT MAX SINCE 1 hour ago", * }, * }); * const engineering = new newrelic.Scorecard("engineering", { * name: "Engineering Standards", * progressLevels: [ * { * id: "foundation", * name: "Foundation", * hexColorCode: "#CC4400", * }, * { * id: "excellence", * name: "Excellence", * hexColorCode: "#00CC44", * }, * ], * ruleIds: [ * alertConfigured.id, * lowLatency.id, * ], * }); * ``` * * Rules are visually grouped under their tier label in the scorecard detail view. Tiers are not hard gates — an entity can pass an `"excellence"` rule without first passing all `"foundation"` rules. Because each rule belongs to only one scorecard, the tier assignment is always unambiguous. * * ## Additional Examples * * ### Disabled rule (paused without deletion) * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const latencyThreshold = new newrelic.ScorecardRule("latency_threshold", { * name: "P95 latency below 500ms", * enabled: false, * runInterval: 720, * nrqlEngine: { * accounts: [accountId], * query: "SELECT if(percentile(duration, 95) < 0.5, 1, 0) AS 'score' FROM Transaction FACET entity.guid LIMIT MAX SINCE 1 hour ago", * }, * }); * ``` * * ### Cross-account rule using `joinAccounts` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const crossAccountErrors = new newrelic.ScorecardRule("cross_account_errors", { * name: "Cross-account error rate below 1%", * enabled: true, * runInterval: 60, * nrqlEngine: { * accounts: [primaryAccountId], * joinAccounts: [secondaryAccountId], * query: "SELECT if(percentage(count(*), WHERE error IS true) < 1.0, 1, 0) AS 'score' FROM Transaction FACET entity.guid LIMIT MAX SINCE 1 hour ago", * }, * }); * ``` * * ### Rule with impact weighting * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as newrelic from "@pulumi/newrelic"; * * const criticalAlertCheck = new newrelic.ScorecardRule("critical_alert_check", { * name: "Critical alerts configured", * enabled: true, * runInterval: 1440, * impactWeight: 3, * nrqlEngine: { * accounts: [accountId], * query: "SELECT if(latest(alertSeverity) = 'CRITICAL', 1, 0) AS 'score' FROM Entity WHERE type = 'APM-APPLICATION' FACET id LIMIT MAX SINCE 1 day ago", * }, * }); * ``` * * ## Import * * Scorecard rules can be imported using the entity GUID: * * ```sh * $ pulumi import newrelic:index/scorecardRule:ScorecardRule example * ``` * * To find a rule's GUID, use `terraform state show` after applying, or query NerdGraph: * * > **NOTE:** Scorecard rules are NGEP entities and are not returned by the `newrelic.getEntity` data source. Use the NerdGraph query above or `terraform state show newrelic_scorecard_rule.example` to retrieve the GUID. */ export declare class ScorecardRule extends pulumi.CustomResource { /** * Get an existing ScorecardRule 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?: ScorecardRuleState, opts?: pulumi.CustomResourceOptions): ScorecardRule; /** * Returns true if the given object is an instance of ScorecardRule. 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 ScorecardRule; /** * A description of what this rule measures. */ readonly description: pulumi.Output; /** * Whether the rule is active. Set to `false` to pause evaluation without deleting the rule. */ readonly enabled: pulumi.Output; /** * A non-negative integer weighting this rule's contribution to the overall scorecard score relative to other rules. Omit for equal weighting. */ readonly impactWeight: pulumi.Output; /** * The name of the rule. */ readonly name: pulumi.Output; /** * A block defining the NRQL query that produces the score. See Nested `nrqlEngine` block below. */ readonly nrqlEngine: pulumi.Output; /** * The organisation UUID, resolved automatically from the provider account. */ readonly organizationId: pulumi.Output; /** * The `id` of a progress tier defined in the parent `newrelic.Scorecard`. Assigns the rule to a visual grouping in the UI. The value must exactly match a `progress_levels.id` on the scorecard (e.g. `"red"`, `"amber"`, `"green"`). Omit to leave the rule ungrouped. See Progress Level Relationship below. */ readonly progressLevel: pulumi.Output; /** * How frequently the NRQL query runs, in minutes. Accepted values: `60` (hourly), `360` (6 hours), `720` (12 hours), `1440` (daily). Omit to use the API default. */ readonly runInterval: pulumi.Output; /** * One or more `tags` blocks assigning key-value metadata to this rule. Tags prefixed with `nr.` are managed by New Relic and are preserved automatically. Each block supports: */ readonly tags: pulumi.Output; /** * Create a ScorecardRule 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: ScorecardRuleArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ScorecardRule resources. */ export interface ScorecardRuleState { /** * A description of what this rule measures. */ description?: pulumi.Input; /** * Whether the rule is active. Set to `false` to pause evaluation without deleting the rule. */ enabled?: pulumi.Input; /** * A non-negative integer weighting this rule's contribution to the overall scorecard score relative to other rules. Omit for equal weighting. */ impactWeight?: pulumi.Input; /** * The name of the rule. */ name?: pulumi.Input; /** * A block defining the NRQL query that produces the score. See Nested `nrqlEngine` block below. */ nrqlEngine?: pulumi.Input; /** * The organisation UUID, resolved automatically from the provider account. */ organizationId?: pulumi.Input; /** * The `id` of a progress tier defined in the parent `newrelic.Scorecard`. Assigns the rule to a visual grouping in the UI. The value must exactly match a `progress_levels.id` on the scorecard (e.g. `"red"`, `"amber"`, `"green"`). Omit to leave the rule ungrouped. See Progress Level Relationship below. */ progressLevel?: pulumi.Input; /** * How frequently the NRQL query runs, in minutes. Accepted values: `60` (hourly), `360` (6 hours), `720` (12 hours), `1440` (daily). Omit to use the API default. */ runInterval?: pulumi.Input; /** * One or more `tags` blocks assigning key-value metadata to this rule. Tags prefixed with `nr.` are managed by New Relic and are preserved automatically. Each block supports: */ tags?: pulumi.Input[] | undefined>; } /** * The set of arguments for constructing a ScorecardRule resource. */ export interface ScorecardRuleArgs { /** * A description of what this rule measures. */ description?: pulumi.Input; /** * Whether the rule is active. Set to `false` to pause evaluation without deleting the rule. */ enabled: pulumi.Input; /** * A non-negative integer weighting this rule's contribution to the overall scorecard score relative to other rules. Omit for equal weighting. */ impactWeight?: pulumi.Input; /** * The name of the rule. */ name?: pulumi.Input; /** * A block defining the NRQL query that produces the score. See Nested `nrqlEngine` block below. */ nrqlEngine: pulumi.Input; /** * The `id` of a progress tier defined in the parent `newrelic.Scorecard`. Assigns the rule to a visual grouping in the UI. The value must exactly match a `progress_levels.id` on the scorecard (e.g. `"red"`, `"amber"`, `"green"`). Omit to leave the rule ungrouped. See Progress Level Relationship below. */ progressLevel?: pulumi.Input; /** * How frequently the NRQL query runs, in minutes. Accepted values: `60` (hourly), `360` (6 hours), `720` (12 hours), `1440` (daily). Omit to use the API default. */ runInterval?: pulumi.Input; /** * One or more `tags` blocks assigning key-value metadata to this rule. Tags prefixed with `nr.` are managed by New Relic and are preserved automatically. Each block supports: */ tags?: pulumi.Input[] | undefined>; } //# sourceMappingURL=scorecardRule.d.ts.map