Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions newrelic/alert-conditions-cloudfront/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ locals {

filter_subquery = length(local.filter_subqueries_and) == 0 ? "" : "WHERE (${local.filter_subqueries_and})"

throughput_count = var.throughput_enabled ? 1 : 0
}

resource "newrelic_nrql_alert_condition" "error_rate" {
Expand Down Expand Up @@ -38,6 +39,20 @@ resource "newrelic_nrql_alert_condition" "error_rate" {
close_violations_on_expiration = false
}

resource "newrelic_entity_tags" "error_rate_tags" {
count = length(var.tags) > 0 ? 1 : 0
guid = newrelic_nrql_alert_condition.error_rate.entity_guid

dynamic "tag" {
for_each = var.tags

content {
key = tag.key
values = try(tolist(tag.value), [tostring(tag.value)])
}
}
}

resource "newrelic_nrql_alert_condition" "throughput" {
count = (var.throughput_enabled ? 1 : 0)

Expand Down Expand Up @@ -66,3 +81,17 @@ resource "newrelic_nrql_alert_condition" "throughput" {
open_violation_on_expiration = false
close_violations_on_expiration = false
}

resource "newrelic_entity_tags" "throughput_tags" {
count = length(var.tags) > 0 ? local.throughput_count : 0
guid = newrelic_nrql_alert_condition.throughput[count.index].entity_guid

dynamic "tag" {
for_each = var.tags

content {
key = tag.key
values = try(tolist(tag.value), [tostring(tag.value)])
}
}
}
6 changes: 6 additions & 0 deletions newrelic/alert-conditions-cloudfront/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ variable "throughput_threshold" {
description = "Minimum number of requests per minute before triggering throughput alert."
default = 5
}

variable "tags" {
type = map(any)
description = "Tags to apply to the alert conditions."
default = {}
}