Skip to content

A Terraform module for New Relic with an opinionated NRQL alert condition.

License

Notifications You must be signed in to change notification settings

USFoods/terraform-newrelic-nrql-alert-condition

Repository files navigation

Terraform New Relic NRQL Alert Condition Module

This module handles opinion New Relic NRQL Alert Condition creation and configuration.

Compatability

This module is meant for use with Terraform 1.0+ and tested using Terraform 1.3+. If you find incompatibilities using Terraform >=1.0, please open an issue.

Usage

There are multiple examples included in the examples folder but simple usage is as follows:

provider "newrelic" {
  account_id = var.account_id
}

resource "newrelic_alert_policy" "main" {
  name                = "Basic Policy"
  incident_preference = "PER_CONDITION_AND_TARGET"
}

// This is the bare minimum configuration required
module "main" {
  source = "usfoods/nrql-alert-condition/newrelic"

  account_id = var.account_id
  policy_id  = newrelic_alert_policy.main.id
  name       = "Basic Critical NRQL Alert Condition"
  enabled    = var.enabled

  query = "SELECT average(duration) FROM Transaction"

  critical = {
    threshold          = 1000
    threshold_duration = 180
  }
}

Then perform the following commands on the root folder:

  • terraform init to get the plugins
  • terraform plan to see the infrastructure plan
  • terraform apply to apply the infrastructure build
  • terraform destroy to destroy the built infrastructure

Requirements

Name Version
terraform >= 1.3
newrelic >=3.14

Providers

Name Version
newrelic >=3.14

Modules

No modules.

Resources

Name Type
newrelic_entity_tags.this resource
newrelic_nrql_alert_condition.this resource

Inputs

Name Description Type Default Required
account_id The New Relic account ID of the account you wish to create the condition string n/a yes
aggregation_delay How long we wait for data that belongs in each aggregation window number 120 no
aggregation_method Determines when we consider an aggregation window to be complete so that we can evaluate the signal for incidents string "event_flow" no
aggregation_timer How long we wait after each data point arrives to make sure we've processed the whole batch number null no
aggregation_window The duration of the time window used to evaluate the NRQL query, in seconds number 60 no
baseline_direction The baseline direction of a baseline NRQL alert condition string null no
close_violations_on_expiration Whether to close all open incidents when the signal expires bool false no
critical The critical violation threshold values
object({
operator = optional(string, "ABOVE")
threshold = number
threshold_duration = number
threshold_occurrences = optional(string, "ALL")
})
n/a yes
description The description of the NRQL alert condition string "" no
enabled Whether to enable the alert condition bool false no
evaluation_delay How long we wait until the signal starts evaluating number null no
expiration_duration The amount of time (in seconds) to wait before considering the signal expired number 900 no
fill_option Which strategy to use when filling gaps in the signal string "none" no
fill_value This value will be used for filling gaps in the signal number null no
name The title of the condition string n/a yes
open_violation_on_expiration Whether to create a new incident to capture that the signal expired bool false no
policy_id The ID of the policy where this condition should be used string n/a yes
query The NRQL query to execute for the condition string n/a yes
runbook_url Runbook URL to display in notifications string "" no
slide_by Gathers data in overlapping time windows to smooth the chart line, making it easier to spot trends number null no
tags The tags associated with the alert condition map(list(string)) {} no
type The type of the condition string "static" no
violation_time_limit_seconds Sets a time limit, in seconds, that will automatically force-close a long-lasting incident after the time limit you select number 86400 no
warning The warning violation threshold values
object({
operator = optional(string, "ABOVE")
threshold = number
threshold_duration = number
threshold_occurrences = optional(string, "ALL")
})
null no

Outputs

Name Description
account_id The New Relic account ID of the account you wish to create the condition
aggregation_delay How long we wait for data that belongs in each aggregation window
aggregation_method When we consider an aggregation window to be complete so that we can evaluate the signal for incidents
aggregation_timer How long we wait after each data point arrives to make sure we've processed the whole batch
aggregation_window The duration of the time window used to evaluate the NRQL query, in seconds
baseline_direction The baseline direction of a baseline NRQL alert condition
close_violations_on_expiration Whether to close all open incidents when the signal expires
critical_operator The operator used when evaluating the threshold
critical_threshold The value which will trigger an incident
critical_threshold_duration The duration, in seconds, that the threshold must violate in order to create an incident
critical_threshold_occurrences The criteria for how many data points must be in violation for the specified threshold duration
description The description of the NRQL alert condition
enabled Whether the alert condition is enabled
entity_guid The unique entity identifier of the NRQL Condition in New Relic
evaluation_delay How long we wait until the signal starts evaluating
expiration_duration The amount of time (in seconds) to wait before considering the signal expired
fill_option Which strategy to use when filling gaps in the signal
fill_value This value to use for filling gaps in the signal
id The ID of the NRQL alert condition
name The title of the condition
nrql_query The NRQL query executed for the condition
open_violation_on_expiration Whether to create a new incident to capture that the signal expired
policy_id The ID of the policy where this condition is used
runbook_url Runbook URL to display in notifications
slide_by Gathers data in overlapping time windows to smooth the chart line, making it easier to spot trends
tags The tags associated with the alert condition
type The type of the condition
violation_time_limit_seconds The time limit, in seconds, that will automatically force-close a long-lasting incident
warning_operator The operator used when evaluating the threshold
warning_threshold The value which will trigger an incident
warning_threshold_duration The duration, in seconds, that the threshold must violate in order to create an incident
warning_threshold_occurrences The criteria for how many data points must be in violation for the specified threshold duration

About

A Terraform module for New Relic with an opinionated NRQL alert condition.

Resources

License

Stars

Watchers

Forks

Packages

No packages published