MON-472 AWS SQS module with two monitors: number of visible messages (disabled by default) and age of the oldest message.
This commit is contained in:
parent
10ca7346a5
commit
08848a9fdb
@ -152,6 +152,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
|||||||
- [mysql](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/aurora/mysql/)
|
- [mysql](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/aurora/mysql/)
|
||||||
- [postgresql](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/aurora/postgresql/)
|
- [postgresql](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/aurora/postgresql/)
|
||||||
- [common](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/common/)
|
- [common](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/common/)
|
||||||
|
- [sqs](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/sqs/)
|
||||||
- [vpn](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/vpn/)
|
- [vpn](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/vpn/)
|
||||||
- [azure](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/)
|
- [azure](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/)
|
||||||
- [apimanagement](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/apimanagement/)
|
- [apimanagement](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/apimanagement/)
|
||||||
|
|||||||
124
cloud/aws/sqs/inputs.tf
Normal file
124
cloud/aws/sqs/inputs.tf
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
# Datadog global variables
|
||||||
|
|
||||||
|
variable "environment" {
|
||||||
|
description = "Architecture environment"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "filter_tags_use_defaults" {
|
||||||
|
description = "Use default filter tags convention"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "filter_tags_custom" {
|
||||||
|
description = "Tags used for custom filtering when filter_tags_use_defaults is false"
|
||||||
|
default = "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "filter_tags_custom_excluded" {
|
||||||
|
description = "Tags excluded for custom filtering when filter_tags_use_defaults is false"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "message" {
|
||||||
|
description = "Message sent when a monitor is triggered"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "evaluation_delay" {
|
||||||
|
description = "Delay in seconds for the metric evaluation"
|
||||||
|
default = 900
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "new_host_delay" {
|
||||||
|
description = "Delay in seconds before monitor new resource"
|
||||||
|
default = 300
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "prefix_slug" {
|
||||||
|
description = "Prefix string to prepend between brackets on every monitors names"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Datadog monitors variables
|
||||||
|
|
||||||
|
# Approximate Number of Visible Messages
|
||||||
|
variable "visible_messages_enabled" {
|
||||||
|
description = "Flag to enable Number of Visible Messages monitor"
|
||||||
|
type = string
|
||||||
|
default = "false"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "visible_messages_extra_tags" {
|
||||||
|
description = "Extra tags for Number of Visible Messages monitor"
|
||||||
|
type = list(string)
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "visible_messages_message" {
|
||||||
|
description = "Custom message for Number of Visible Messages monitor"
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "visible_messages_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Number of Visible Messages [available values: min, max or avg]"
|
||||||
|
type = string
|
||||||
|
default = "min"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "visible_messages_timeframe" {
|
||||||
|
description = "Monitor timeframe for Number of Visible Messages [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = string
|
||||||
|
default = "last_30m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "visible_messages_threshold_critical" {
|
||||||
|
default = 2
|
||||||
|
description = "Alerting threshold in number of messages"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "visible_messages_threshold_warning" {
|
||||||
|
default = 1
|
||||||
|
description = "Warning threshold in number of messages"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Age of the Oldest Message
|
||||||
|
variable "age_of_oldest_message_enabled" {
|
||||||
|
description = "Flag to enable Age of Oldest Message monitor"
|
||||||
|
type = string
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "age_of_oldest_message_extra_tags" {
|
||||||
|
description = "Extra tags for Age of Oldest Message monitor"
|
||||||
|
type = list(string)
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "age_of_oldest_message_message" {
|
||||||
|
description = "Custom message for Age of Oldest Message monitor"
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "age_of_oldest_message_time_aggregator" {
|
||||||
|
description = "Monitor aggregator for Age of Oldest Message [available values: min, max or avg]"
|
||||||
|
type = string
|
||||||
|
default = "min"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "age_of_oldest_message_timeframe" {
|
||||||
|
description = "Monitor timeframe for Age of Oldest Message [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
|
type = string
|
||||||
|
default = "last_30m"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "age_of_oldest_message_threshold_critical" {
|
||||||
|
default = 600
|
||||||
|
description = "Alerting threshold in seconds"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "age_of_oldest_message_threshold_warning" {
|
||||||
|
default = 300
|
||||||
|
description = "Warning threshold in seconds"
|
||||||
|
}
|
||||||
9
cloud/aws/sqs/modules.tf
Normal file
9
cloud/aws/sqs/modules.tf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module "filter-tags" {
|
||||||
|
source = "../../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = var.environment
|
||||||
|
resource = "aws_sqs"
|
||||||
|
filter_tags_use_defaults = var.filter_tags_use_defaults
|
||||||
|
filter_tags_custom = var.filter_tags_custom
|
||||||
|
filter_tags_custom_excluded = var.filter_tags_custom_excluded
|
||||||
|
}
|
||||||
69
cloud/aws/sqs/monitors-sqs.tf
Normal file
69
cloud/aws/sqs/monitors-sqs.tf
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# Approximate Number of Visible Messages
|
||||||
|
resource "datadog_monitor" "visible_messages" {
|
||||||
|
count = var.visible_messages_enabled == "true" ? 1 : 0
|
||||||
|
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Number of messages visible {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||||
|
type = "metric alert"
|
||||||
|
message = coalesce(var.visible_messages_message, var.message)
|
||||||
|
|
||||||
|
query = <<EOQ
|
||||||
|
${var.visible_messages_time_aggregator}(${var.visible_messages_timeframe}):
|
||||||
|
avg:aws.sqs.approximate_number_of_messages_visible${module.filter-tags.query_alert} by {region,queuename}
|
||||||
|
> ${var.visible_messages_threshold_critical}
|
||||||
|
EOQ
|
||||||
|
|
||||||
|
thresholds = {
|
||||||
|
critical = var.visible_messages_threshold_critical
|
||||||
|
warning = var.visible_messages_threshold_warning
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluation_delay = var.evaluation_delay
|
||||||
|
new_host_delay = var.new_host_delay
|
||||||
|
notify_no_data = false
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = false
|
||||||
|
|
||||||
|
tags = concat(["env:${var.environment}", "type:cloud", "provider:aws", "resource:sqs", "team:claranet", "created-by:terraform"], var.visible_messages_extra_tags)
|
||||||
|
|
||||||
|
lifecycle {
|
||||||
|
ignore_changes = ["silenced"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Age of the Oldest Message
|
||||||
|
resource "datadog_monitor" "age_of_oldest_message" {
|
||||||
|
count = var.age_of_oldest_message_enabled == "true" ? 1 : 0
|
||||||
|
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Age of the oldest message {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||||
|
type = "metric alert"
|
||||||
|
message = coalesce(var.age_of_oldest_message_message, var.message)
|
||||||
|
|
||||||
|
query = <<EOQ
|
||||||
|
${var.age_of_oldest_message_time_aggregator}(${var.age_of_oldest_message_timeframe}):
|
||||||
|
avg:aws.sqs.approximate_age_of_oldest_message${module.filter-tags.query_alert} by {region,queuename}
|
||||||
|
> ${var.age_of_oldest_message_threshold_critical}
|
||||||
|
EOQ
|
||||||
|
|
||||||
|
thresholds = {
|
||||||
|
critical = var.age_of_oldest_message_threshold_critical
|
||||||
|
warning = var.age_of_oldest_message_threshold_warning
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluation_delay = var.evaluation_delay
|
||||||
|
new_host_delay = var.new_host_delay
|
||||||
|
notify_no_data = false
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = false
|
||||||
|
|
||||||
|
tags = concat(["env:${var.environment}", "type:cloud", "provider:aws", "resource:sqs", "team:claranet", "created-by:terraform"], var.age_of_oldest_message_extra_tags)
|
||||||
|
|
||||||
|
lifecycle {
|
||||||
|
ignore_changes = ["silenced"]
|
||||||
|
}
|
||||||
|
}
|
||||||
10
cloud/aws/sqs/outputs.tf
Normal file
10
cloud/aws/sqs/outputs.tf
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
output "age_of_oldest_message_id" {
|
||||||
|
description = "id for monitor age_of_oldest_message"
|
||||||
|
value = datadog_monitor.age_of_oldest_message.*.id
|
||||||
|
}
|
||||||
|
|
||||||
|
output "visible_messages_id" {
|
||||||
|
description = "id for monitor visible_messages"
|
||||||
|
value = datadog_monitor.visible_messages.*.id
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user