Skip to content

Commit

Permalink
Merge pull request #142 from claranet/body_template
Browse files Browse the repository at this point in the history
  • Loading branch information
xp-1000 authored Oct 12, 2020
2 parents e1d35df + 39df30f commit d4231f2
Show file tree
Hide file tree
Showing 289 changed files with 2,134 additions and 4,376 deletions.
1 change: 1 addition & 0 deletions cloud/aws/alb/common-locals.tf
1 change: 1 addition & 0 deletions cloud/aws/alb/common-variables.tf
53 changes: 33 additions & 20 deletions cloud/aws/alb/detectors-alb.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "signalfx_detector" "heartbeat" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB heartbeat"
name = format("%s %s", local.detector_name_prefix, "AWS ALB heartbeat")

program_text = <<-EOF
from signalfx.detectors.not_reporting import not_reporting
Expand All @@ -13,12 +13,13 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.heartbeat_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.heartbeat_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} on {{{dimensions}}}"
parameterized_subject = local.rule_subject_novalue
parameterized_body = local.rule_body
}
}

resource "signalfx_detector" "no_healthy_instances" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB healthy instances percentage"
name = format("%s %s", local.detector_name_prefix, "AWS ALB healthy instances percentage")

program_text = <<-EOF
A = data('HealthyHostCount', filter=filter('namespace', 'AWS/ApplicationELB') and filter('stat', 'lower') and (not filter('AvailabilityZone', '*')) and ${module.filter-tags.filter_custom})${var.no_healthy_instances_aggregation_function}${var.no_healthy_instances_transformation_function}
Expand All @@ -34,7 +35,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.no_healthy_instances_disabled_critical, var.no_healthy_instances_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.no_healthy_instances_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -43,12 +45,13 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.no_healthy_instances_disabled_major, var.no_healthy_instances_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.no_healthy_instances_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

resource "signalfx_detector" "latency" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB latency"
name = format("%s %s", local.detector_name_prefix, "AWS ALB latency")

program_text = <<-EOF
signal = data('TargetResponseTime', filter=filter('namespace', 'AWS/ApplicationELB') and filter('stat', 'mean') and filter('TargetGroup', '*') and (not filter('AvailabilityZone', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='average')${var.latency_aggregation_function}${var.latency_transformation_function}.publish('signal')
Expand All @@ -62,7 +65,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.latency_disabled_critical, var.latency_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.latency_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -71,12 +75,13 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.latency_disabled_major, var.latency_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.latency_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

resource "signalfx_detector" "alb_5xx" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB 5xx error rate"
name = format("%s %s", local.detector_name_prefix, "AWS ALB 5xx error rate")

program_text = <<-EOF
A = data('HTTPCode_ELB_5XX_Count', filter=filter('namespace', 'AWS/ApplicationELB') and filter('stat', 'sum') and (not filter('AvailabilityZone', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='sum')${var.alb_5xx_aggregation_function}${var.alb_5xx_transformation_function}
Expand All @@ -92,7 +97,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.alb_5xx_disabled_critical, var.alb_5xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.alb_5xx_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -101,12 +107,13 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.alb_5xx_disabled_major, var.alb_5xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.alb_5xx_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

resource "signalfx_detector" "alb_4xx" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB 4xx error rate"
name = format("%s %s", local.detector_name_prefix, "AWS ALB 4xx error rate")

program_text = <<-EOF
A = data('HTTPCode_ELB_4XX_Count', filter=filter('namespace', 'AWS/ApplicationELB') and filter('stat', 'sum') and (not filter('AvailabilityZone', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='sum')${var.alb_4xx_aggregation_function}${var.alb_4xx_transformation_function}
Expand All @@ -122,7 +129,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.alb_4xx_disabled_critical, var.alb_4xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.alb_4xx_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -131,12 +139,13 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.alb_4xx_disabled_major, var.alb_4xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.alb_4xx_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

resource "signalfx_detector" "target_5xx" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB target 5xx error rate"
name = format("%s %s", local.detector_name_prefix, "AWS ALB target 5xx error rate")

program_text = <<-EOF
A = data('HTTPCode_Target_5XX_Count', filter=filter('namespace', 'AWS/ApplicationELB') and filter('stat', 'sum') and filter('TargetGroup', '*') and (not filter('AvailabilityZone', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='sum')${var.target_5xx_aggregation_function}${var.target_5xx_transformation_function}
Expand All @@ -152,7 +161,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.target_5xx_disabled_critical, var.target_5xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.target_5xx_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -161,12 +171,13 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.target_5xx_disabled_major, var.target_5xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.target_5xx_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

resource "signalfx_detector" "target_4xx" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ALB target 4xx error rate"
name = format("%s %s", local.detector_name_prefix, "AWS ALB target 4xx error rate")

program_text = <<-EOF
A = data('HTTPCode_Target_4XX_Count', filter=filter('namespace', 'AWS/ApplicationELB') and filter('stat', 'sum') and filter('TargetGroup', '*') and (not filter('AvailabilityZone', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='sum')${var.target_4xx_aggregation_function}${var.target_4xx_transformation_function}
Expand All @@ -182,7 +193,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.target_4xx_disabled_critical, var.target_4xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.target_4xx_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -191,7 +203,8 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.target_4xx_disabled_major, var.target_4xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.target_4xx_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

60 changes: 9 additions & 51 deletions cloud/aws/alb/variables.tf
Original file line number Diff line number Diff line change
@@ -1,55 +1,13 @@
# Global

variable "environment" {
description = "Infrastructure environment"
type = string
}

# SignalFx module specific

variable "notifications" {
description = "Default notification recipients list per severity"
type = object({
critical = list(string)
major = list(string)
minor = list(string)
warning = list(string)
info = list(string)
})
}

variable "prefixes" {
description = "Prefixes list to prepend between brackets on every monitors names before environment"
type = list
default = []
}

variable "filter_custom_includes" {
description = "List of tags to include when custom filtering is used"
type = list
default = []
}

variable "filter_custom_excludes" {
description = "List of tags to exclude when custom filtering is used"
type = list
default = []
}

variable "detectors_disabled" {
description = "Disable all detectors in this module"
type = bool
default = false
}

# AWS Alb detectors specific
# Module specific

variable "minimum_traffic" {
description = "Minimum required traffic to evaluate rate of errors detectors"
type = number
default = 4
}

# Heartbeat detector

variable "heartbeat_disabled" {
description = "Disable all alerting rules for heartbeat detector"
type = bool
Expand All @@ -74,7 +32,7 @@ variable "heartbeat_aggregation_function" {
default = ".mean(by=['LoadBalancer'])"
}

# No_healthy_instances detectors
# No_healthy_instances detector

variable "no_healthy_instances_disabled" {
description = "Disable all alerting rules for No_healthy_instances detector"
Expand Down Expand Up @@ -124,7 +82,7 @@ variable "no_healthy_instances_threshold_major" {
default = 100
}

# Latency detectors
# Latency detector

variable "latency_disabled" {
description = "Disable all alerting rules for latency detector"
Expand Down Expand Up @@ -186,7 +144,7 @@ variable "latency_threshold_major" {
default = 1
}

# alb_5xx detectors
# alb_5xx detector

variable "alb_5xx_disabled" {
description = "Disable all alerting rules for alb_5xx detector"
Expand Down Expand Up @@ -248,7 +206,7 @@ variable "alb_5xx_threshold_major" {
default = 5
}

# alb_4xx detectors
# alb_4xx detector

variable "alb_4xx_disabled" {
description = "Disable all alerting rules for alb_4xx detector"
Expand Down Expand Up @@ -310,7 +268,7 @@ variable "alb_4xx_threshold_major" {
default = 20
}

# target_5xx detectors
# target_5xx detector

variable "target_5xx_disabled" {
description = "Disable all alerting rules for target_5xx detector"
Expand Down Expand Up @@ -372,7 +330,7 @@ variable "target_5xx_threshold_major" {
default = 5
}

# target_4xx detectors
# target_4xx detector

variable "target_4xx_disabled" {
description = "Disable all alerting rules for target_4xx detector"
Expand Down
1 change: 1 addition & 0 deletions cloud/aws/apigateway/common-locals.tf
1 change: 1 addition & 0 deletions cloud/aws/apigateway/common-variables.tf
24 changes: 15 additions & 9 deletions cloud/aws/apigateway/detectors-api.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monitoring Api Gateway latency
resource "signalfx_detector" "latency" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ApiGateway latency"
name = format("%s %s", local.detector_name_prefix, "AWS ApiGateway latency")

program_text = <<-EOF
signal = data('Latency', filter=filter('namespace', 'AWS/ApiGateway') and filter('stat', 'sum') and (not filter('Stage', '*')) and (not filter('Method', '*')) and (not filter('Resource', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='average')${var.latency_aggregation_function}${var.latency_transformation_function}.publish('signal')
Expand All @@ -14,7 +14,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.latency_disabled_critical, var.latency_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.latency_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -23,13 +24,14 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.latency_disabled_major, var.latency_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.latency_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

# Monitoring API Gateway 5xx errors percent
resource "signalfx_detector" "http_5xx" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ApiGateway HTTP 5xx error rate"
name = format("%s %s", local.detector_name_prefix, "AWS ApiGateway HTTP 5xx error rate")

program_text = <<-EOF
A = data('${var.is_v2 ? "5xx" : "5XXError"}', filter=filter('namespace', 'AWS/ApiGateway') and filter('stat', 'sum') and (not filter('Stage', '*')) and (not filter('Method', '*')) and (not filter('Resource', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='sum')${var.http_5xx_aggregation_function}${var.http_5xx_transformation_function}
Expand All @@ -45,7 +47,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.http_5xx_disabled_critical, var.http_5xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.http_5xx_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -54,13 +57,14 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.http_5xx_disabled_major, var.http_5xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.http_5xx_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

# Monitoring API Gateway 4xx errors percent
resource "signalfx_detector" "http_4xx" {
name = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}] AWS ApiGateway HTTP 4xx error rate"
name = format("%s %s", local.detector_name_prefix, "AWS ApiGateway HTTP 4xx error rate")

program_text = <<-EOF
A = data('${var.is_v2 ? "4xx" : "4XXError"}', filter=filter('namespace', 'AWS/ApiGateway') and filter('stat', 'sum') and (not filter('Stage', '*')) and (not filter('Method', '*')) and (not filter('Resource', '*')) and ${module.filter-tags.filter_custom}, extrapolation='zero', rollup='sum')${var.http_4xx_aggregation_function}${var.http_4xx_transformation_function}
Expand All @@ -76,7 +80,8 @@ EOF
detect_label = "CRIT"
disabled = coalesce(var.http_4xx_disabled_critical, var.http_4xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.http_4xx_notifications, "critical", []), var.notifications.critical)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}

rule {
Expand All @@ -85,7 +90,8 @@ EOF
detect_label = "MAJOR"
disabled = coalesce(var.http_4xx_disabled_major, var.http_4xx_disabled, var.detectors_disabled)
notifications = coalescelist(lookup(var.http_4xx_notifications, "major", []), var.notifications.major)
parameterized_subject = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}}) on {{{dimensions}}}"
parameterized_subject = local.rule_subject
parameterized_body = local.rule_body
}
}

Loading

0 comments on commit d4231f2

Please sign in to comment.