Merge branch 'MON-472-aws-sqs-tf012' into 'master'
MON-472 module for AWS SQS See merge request claranet/pt-monitoring/projects/datadog/terraform/monitors!108
This commit is contained in:
commit
2b8124fa4f
@ -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/)
|
||||
- [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/)
|
||||
- [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/)
|
||||
- [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/)
|
||||
|
||||
58
cloud/aws/sqs/README.md
Normal file
58
cloud/aws/sqs/README.md
Normal file
@ -0,0 +1,58 @@
|
||||
# CLOUD AWS SQS DataDog monitors
|
||||
|
||||
## How to use this module
|
||||
|
||||
```
|
||||
module "datadog-monitors-cloud-aws-sqs" {
|
||||
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/sqs?ref={revision}"
|
||||
|
||||
environment = var.environment
|
||||
message = module.datadog-message-alerting.alerting-message
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
Creates DataDog monitors with the following checks:
|
||||
|
||||
- SQS Age of the oldest message
|
||||
- SQS Visible messages (disabled by default)
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| age\_of\_oldest\_message\_enabled | Flag to enable Age of Oldest Message monitor | string | `"true"` | no |
|
||||
| age\_of\_oldest\_message\_extra\_tags | Extra tags for Age of Oldest Message monitor | list(string) | `[]` | no |
|
||||
| age\_of\_oldest\_message\_message | Custom message for Age of Oldest Message monitor | string | `""` | no |
|
||||
| age\_of\_oldest\_message\_threshold\_critical | Alerting threshold in seconds | string | `"600"` | no |
|
||||
| age\_of\_oldest\_message\_threshold\_warning | Warning threshold in seconds | string | `"300"` | no |
|
||||
| age\_of\_oldest\_message\_time\_aggregator | Monitor aggregator for Age of Oldest Message [available values: min, max or avg] | string | `"min"` | no |
|
||||
| age\_of\_oldest\_message\_timeframe | 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`] | string | `"last_30m"` | no |
|
||||
| environment | Architecture environment | string | n/a | yes |
|
||||
| evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no |
|
||||
| filter\_tags\_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `"*"` | no |
|
||||
| filter\_tags\_custom\_excluded | Tags excluded for custom filtering when filter_tags_use_defaults is false | string | `""` | no |
|
||||
| filter\_tags\_use\_defaults | Use default filter tags convention | string | `"true"` | no |
|
||||
| message | Message sent when a monitor is triggered | string | n/a | yes |
|
||||
| new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no |
|
||||
| prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no |
|
||||
| visible\_messages\_enabled | Flag to enable Number of Visible Messages monitor | string | `"false"` | no |
|
||||
| visible\_messages\_extra\_tags | Extra tags for Number of Visible Messages monitor | list(string) | `[]` | no |
|
||||
| visible\_messages\_message | Custom message for Number of Visible Messages monitor | string | `""` | no |
|
||||
| visible\_messages\_threshold\_critical | Alerting threshold in number of messages | string | `"2"` | no |
|
||||
| visible\_messages\_threshold\_warning | Warning threshold in number of messages | string | `"1"` | no |
|
||||
| visible\_messages\_time\_aggregator | Monitor aggregator for Number of Visible Messages [available values: min, max or avg] | string | `"min"` | no |
|
||||
| visible\_messages\_timeframe | 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`] | string | `"last_30m"` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| age\_of\_oldest\_message\_id | id for monitor age_of_oldest_message |
|
||||
| visible\_messages\_id | id for monitor visible_messages |
|
||||
|
||||
## Related documentation
|
||||
* [Datadog Documentation](https://docs.datadoghq.com/integrations/amazon_sqs/)
|
||||
* [Service Documentation](https://docs.aws.amazon.com/sqs/index.html)
|
||||
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}] SQS Visible messages {{#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}] SQS Age of the oldest message {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/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