diff --git a/cloud/aws/rds/aurora/mysql/README.md b/cloud/aws/rds/aurora/mysql/README.md index a4d9ae1..bf01779 100644 --- a/cloud/aws/rds/aurora/mysql/README.md +++ b/cloud/aws/rds/aurora/mysql/README.md @@ -22,8 +22,8 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| aurora_replicalag_enabled | Flag to enable RDS CPU usage monitor | string | `true` | no | -| aurora_replicalag_extra_tags | Extra tags for RDS CPU usage monitor | list | `` | no | +| aurora_replicalag_enabled | Flag to enable RDS Aurora replica lag monitor | string | `true` | no | +| aurora_replicalag_extra_tags | Extra tags for RDS Aurora replica lag monitor | list | `` | no | | aurora_replicalag_message | Custom message for RDS Aurora replica lag monitor | string | `` | no | | aurora_replicalag_silenced | Groups to mute for RDS Aurora replica lag monitor | map | `` | no | | aurora_replicalag_threshold_critical | Aurora replica lag in milliseconds (critical threshold) | string | `200` | no | diff --git a/cloud/aws/rds/aurora/postgresql/README.md b/cloud/aws/rds/aurora/postgresql/README.md index 0674fb7..9f6f6d7 100644 --- a/cloud/aws/rds/aurora/postgresql/README.md +++ b/cloud/aws/rds/aurora/postgresql/README.md @@ -22,8 +22,8 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| aurora_replicalag_enabled | Flag to enable RDS CPU usage monitor | string | `true` | no | -| aurora_replicalag_extra_tags | Extra tags for RDS CPU usage monitor | list | `` | no | +| aurora_replicalag_enabled | Flag to enable RDS Aurora replica lag monitor | string | `true` | no | +| aurora_replicalag_extra_tags | Extra tags for RDS Aurora replica lag monitor | list | `` | no | | aurora_replicalag_message | Custom message for RDS Aurora replica lag monitor | string | `` | no | | aurora_replicalag_silenced | Groups to mute for RDS Aurora replica lag monitor | map | `` | no | | aurora_replicalag_threshold_critical | Aurora replica lag in milliseconds (critical threshold) | string | `200` | no | diff --git a/cloud/aws/rds/common/README.md b/cloud/aws/rds/common/README.md index 1abb93e..0337b2f 100644 --- a/cloud/aws/rds/common/README.md +++ b/cloud/aws/rds/common/README.md @@ -18,6 +18,7 @@ Creates DataDog monitors with the following checks: - RDS instance CPU high - RDS instance free space +- RDS replica lag ## Inputs @@ -45,6 +46,13 @@ Creates DataDog monitors with the following checks: | filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | | message | Message sent when an alert is triggered | string | - | yes | | new_host_delay | Delay in seconds before monitor new resource | string | `300` | no | +| replicalag_enabled | Flag to enable RDS replica lag monitor | string | `true` | no | +| replicalag_extra_tags | Extra tags for RDS replica lag monitor | list | `` | no | +| replicalag_message | Custom message for RDS replica lag monitor | string | `` | no | +| replicalag_silenced | Groups to mute for RDS replica lag monitor | map | `` | no | +| replicalag_threshold_critical | replica lag in seconds (critical threshold) | string | `300` | no | +| replicalag_threshold_warning | replica lag in seconds (warning threshold) | string | `200` | no | +| replicalag_timeframe | Monitor timeframe for RDS replica lag monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | ## Outputs @@ -52,6 +60,7 @@ Creates DataDog monitors with the following checks: |------|-------------| | rds_cpu_90_15min_id | id for monitor rds_cpu_90_15min | | rds_free_space_low_id | id for monitor rds_free_space_low | +| rds_replica_lag_id | id for monitor rds_replica_lag | ## Related documentation diff --git a/cloud/aws/rds/common/inputs.tf b/cloud/aws/rds/common/inputs.tf index 54cf425..c046875 100644 --- a/cloud/aws/rds/common/inputs.tf +++ b/cloud/aws/rds/common/inputs.tf @@ -122,3 +122,43 @@ variable "diskspace_threshold_critical" { description = "Disk free space in percent (critical threshold)" default = "10" } + +variable "replicalag_silenced" { + description = "Groups to mute for RDS replica lag monitor" + type = "map" + default = {} +} + +variable "replicalag_enabled" { + description = "Flag to enable RDS replica lag monitor" + type = "string" + default = "true" +} + +variable "replicalag_extra_tags" { + description = "Extra tags for RDS replica lag monitor" + type = "list" + default = [] +} + +variable "replicalag_message" { + description = "Custom message for RDS replica lag monitor" + type = "string" + default = "" +} + +variable "replicalag_timeframe" { + description = "Monitor timeframe for RDS replica lag monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_5m" +} + +variable "replicalag_threshold_warning" { + description = "replica lag in seconds (warning threshold)" + default = "200" +} + +variable "replicalag_threshold_critical" { + description = "replica lag in seconds (critical threshold)" + default = "300" +} diff --git a/cloud/aws/rds/common/monitors-rds-common.tf b/cloud/aws/rds/common/monitors-rds-common.tf index 3168194..fdf5105 100644 --- a/cloud/aws/rds/common/monitors-rds-common.tf +++ b/cloud/aws/rds/common/monitors-rds-common.tf @@ -64,3 +64,36 @@ EOF tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds", "team:claranet", "created-by:terraform", "${var.diskspace_extra_tags}"] } + +### RDS Replica Lag monitor ### +resource "datadog_monitor" "rds_replica_lag" { + count = "${var.replicalag_enabled ? 1 : 0}" + name = "[${var.environment}] RDS replica lag {{#is_alert}}{{{comparator}}} {{threshold}} ms ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ms ({{value}}%){{/is_warning}}" + message = "${coalesce(var.replicalag_message, var.message)}" + + type = "metric alert" + + query = < ${var.replicalag_threshold_critical} +EOF + + thresholds { + warning = "${var.replicalag_threshold_warning}" + critical = "${var.replicalag_threshold_critical}" + } + + notify_no_data = true + evaluation_delay = "${var.evaluation_delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = false + new_host_delay = "${var.new_host_delay}" + + silenced = "${var.replicalag_silenced}" + + tags = ["env:${var.environment}", "type:cloud", "provider:aws", "resource:rds", "team:claranet", "created-by:terraform", "${var.replicalag_extra_tags}"] +} diff --git a/cloud/aws/rds/common/outputs.tf b/cloud/aws/rds/common/outputs.tf index 4d2c8c5..e112047 100644 --- a/cloud/aws/rds/common/outputs.tf +++ b/cloud/aws/rds/common/outputs.tf @@ -7,3 +7,8 @@ output "rds_free_space_low_id" { description = "id for monitor rds_free_space_low" value = "${datadog_monitor.rds_free_space_low.*.id}" } + +output "rds_replica_lag_id" { + description = "id for monitor rds_replica_lag" + value = "${datadog_monitor.rds_replica_lag.*.id}" +}