From deb5fe67bce8502940a9ed078e55375f31633a1d Mon Sep 17 00:00:00 2001 From: Rafael Romero Carmona Date: Mon, 30 Jul 2018 12:33:31 +0200 Subject: [PATCH] MON-224 Added the variable to control monitor creation --- cloud/gcp/cloud-sql/instance/README.md | 6 ++++ cloud/gcp/cloud-sql/instance/inputs.tf | 35 +++++++++++++++++++ .../instance/monitors-cloud-sql-instance.tf | 12 +++++++ cloud/gcp/cloud-sql/mysql/README.md | 4 +++ cloud/gcp/cloud-sql/mysql/inputs.tf | 24 +++++++++++++ .../mysql/monitors-cloudsql-mysql.tf | 8 +++++ 6 files changed, 89 insertions(+) diff --git a/cloud/gcp/cloud-sql/instance/README.md b/cloud/gcp/cloud-sql/instance/README.md index 60e7dbb..8e5ae36 100644 --- a/cloud/gcp/cloud-sql/instance/README.md +++ b/cloud/gcp/cloud-sql/instance/README.md @@ -27,6 +27,7 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| +| cpu_utilization_enabled | Whether or not to create the monitor | string | `true` | no | | cpu_utilization_extra_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list | `` | no | | cpu_utilization_message | Custom message for the CPU Utilization monitor | string | `` | no | | cpu_utilization_silenced | Groups to mute for GCP Cloud SQL CPU Utilization monitor | map | `` | no | @@ -34,7 +35,9 @@ Creates DataDog monitors with the following checks: | cpu_utilization_threshold_warning | CPU Utilization in percentage (warning threshold) | string | `80` | no | | cpu_utilization_timeframe | Timeframe for the CPU Utilization monitor | string | `last_15m` | no | | delay | Delay in seconds for the metric evaluation | string | `900` | no | +| disk_utilization_enabled | Whether or not to create the monitor | string | `true` | no | | disk_utilization_extra_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list | `` | no | +| disk_utilization_forecast_enabled | Whether or not to create the monitor | string | `true` | no | | disk_utilization_forecast_extra_tags | Extra tags for GCP Cloud SQL CPU Utilization monitor | list | `` | no | | disk_utilization_forecast_message | Custom message for the Disk Utilization monitor | string | `` | no | | disk_utilization_forecast_silenced | Groups to mute for GCP Cloud SQL Disk Utilization monitor | map | `` | no | @@ -47,6 +50,7 @@ Creates DataDog monitors with the following checks: | disk_utilization_threshold_warning | Disk Utilization in percentage (warning threshold) | string | `80` | no | | disk_utilization_timeframe | Timeframe for the Disk Utilization monitor | string | `last_5m` | no | | environment | Architecture environment | string | - | yes | +| failover_unavailable_enabled | Whether or not to create the monitor | string | `true` | no | | failover_unavailable_extra_tags | Extra tags for GCP Cloud SQL Failover Unavailable monitor | list | `` | no | | failover_unavailable_message | Custom message for the Failover Unavailable monitor | string | `` | no | | failover_unavailable_silenced | Groups to mute for GCP Cloud SQL Failover Unavailable monitor | map | `` | no | @@ -54,7 +58,9 @@ Creates DataDog monitors with the following checks: | failover_unavailable_timeframe | Timeframe for the Failover Unavailable monitor | string | `last_5m` | no | | filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | | filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | +| memory_utilization_enabled | Whether or not to create the monitor | string | `true` | no | | memory_utilization_extra_tags | Extra tags for GCP Cloud SQL Memory Utilization monitor | list | `` | no | +| memory_utilization_forecast_enabled | Whether or not to create the monitor | string | `true` | no | | memory_utilization_forecast_extra_tags | Extra tags for GCP Cloud SQL Memory Utilization Forecast monitor | list | `` | no | | memory_utilization_forecast_history | History for the Memory Utilization Forecast monitor | string | `12h` | no | | memory_utilization_forecast_interval | Interval for the Memory Utilization Forecast monitor | string | `30m` | no | diff --git a/cloud/gcp/cloud-sql/instance/inputs.tf b/cloud/gcp/cloud-sql/instance/inputs.tf index 845f679..5513b83 100644 --- a/cloud/gcp/cloud-sql/instance/inputs.tf +++ b/cloud/gcp/cloud-sql/instance/inputs.tf @@ -36,6 +36,12 @@ variable "project_id" { # # CPU # +variable "cpu_utilization_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "cpu_utilization_message" { description = "Custom message for the CPU Utilization monitor" type = "string" @@ -75,6 +81,12 @@ variable "cpu_utilization_extra_tags" { # # DISK Utilization # +variable "disk_utilization_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "disk_utilization_message" { description = "Custom message for the Disk Utilization monitor" type = "string" @@ -114,6 +126,12 @@ variable "disk_utilization_extra_tags" { # # DISK Utilization Forecast # +variable "disk_utilization_forecast_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "disk_utilization_forecast_message" { description = "Custom message for the Disk Utilization monitor" type = "string" @@ -153,6 +171,12 @@ variable "disk_utilization_forecast_extra_tags" { # # Memory Utilization # +variable "memory_utilization_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "memory_utilization_message" { description = "Custom message for the Memory Utilization monitor" default = "" @@ -188,6 +212,12 @@ variable "memory_utilization_extra_tags" { # # Memory Utilization Forecast # +variable "memory_utilization_forecast_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "memory_utilization_forecast_message" { description = "Custom message for the Memory Utilization Forecast monitor" default = "" @@ -233,6 +263,11 @@ variable "memory_utilization_forecast_extra_tags" { # # Failover Unavailable # +variable "failover_unavailable_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} variable "failover_unavailable_message" { description = "Custom message for the Failover Unavailable monitor" diff --git a/cloud/gcp/cloud-sql/instance/monitors-cloud-sql-instance.tf b/cloud/gcp/cloud-sql/instance/monitors-cloud-sql-instance.tf index 3135966..0efc1fa 100644 --- a/cloud/gcp/cloud-sql/instance/monitors-cloud-sql-instance.tf +++ b/cloud/gcp/cloud-sql/instance/monitors-cloud-sql-instance.tf @@ -15,6 +15,8 @@ data "template_file" "filter" { # CPU Utilization # resource "datadog_monitor" "cpu_utilization" { + count = "${var.cpu_utilization_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL CPU utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.cpu_utilization_message, var.message)}" @@ -60,6 +62,8 @@ EOF # Disk Utilization # resource "datadog_monitor" "disk_utilization" { + count = "${var.disk_utilization_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL Disk utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.disk_utilization_message, var.message)}" @@ -105,6 +109,8 @@ EOF # Disk Utilization Forecast # resource "datadog_monitor" "disk_utilization_forecast" { + count = "${var.disk_utilization_forecast_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL Disk utilization could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future" message = "${coalesce(var.disk_utilization_forecast_message, var.message)}" @@ -155,6 +161,8 @@ EOF # Memory Utilization # resource "datadog_monitor" "memory_utilization" { + count = "${var.memory_utilization_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL Memory Utilization {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.memory_utilization_message, var.message)}" @@ -200,6 +208,8 @@ EOF # Memory Utilization Forecast # resource "datadog_monitor" "memory_utilization_forecast" { + count = "${var.memory_utilization_forecast_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL Memory Utilization could reach {{#is_alert}}{{threshold}}%{{/is_alert}} in a near future" message = "${coalesce(var.memory_utilization_forecast_message, var.message)}" @@ -250,6 +260,8 @@ EOF # Failover Unavailable # resource "datadog_monitor" "failover_unavailable" { + count = "${var.failover_unavailable_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL Failover Unavailable" message = "${coalesce(var.failover_unavailable_message, var.message)}" diff --git a/cloud/gcp/cloud-sql/mysql/README.md b/cloud/gcp/cloud-sql/mysql/README.md index dad3956..e10dde1 100644 --- a/cloud/gcp/cloud-sql/mysql/README.md +++ b/cloud/gcp/cloud-sql/mysql/README.md @@ -30,6 +30,7 @@ Creates DataDog monitors with the following checks: | filter_tags_custom | Tags used 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 | - | yes | +| network_connections_enabled | Whether or not to create the monitor | string | `true` | no | | network_connections_extra_tags | Extra tags for GCP Cloud SQL Network Connections monitor | list | `` | no | | network_connections_hard_limit | Max number of connections for the CloudSQL Instance. Default value is the max value on https://cloud.google.com/sql/docs/quotas#fixed-limits for MySQL | string | `4000` | no | | network_connections_message | Custom message for the Network Connections monitor | string | `` | no | @@ -42,6 +43,7 @@ Creates DataDog monitors with the following checks: | queries_changing_database_ids | List of database ids for the Queries Changing monitor | list | `` | no | | queries_changing_deviations | Deviations to detect the anomaly | string | `4` | no | | queries_changing_direction | Direction of the anomaly. It can be both, below or above. | string | `both` | no | +| queries_changing_enabled | Whether or not to create the monitor | string | `true` | no | | queries_changing_extra_tags | Extra tags for GCP Cloud SQL Queries Changing monitor | list | `` | no | | queries_changing_message | Custom message for the Queries Changing monitor | string | `` | no | | queries_changing_seasonality | Seasonality of the algorithm | string | `weekly` | no | @@ -54,6 +56,7 @@ Creates DataDog monitors with the following checks: | questions_changing_database_ids | List of database ids for the Questions Changing monitor | list | `` | no | | questions_changing_deviations | Deviations to detect the anomaly | string | `4` | no | | questions_changing_direction | Direction of the anomaly. It can be both, below or above. | string | `both` | no | +| questions_changing_enabled | Whether or not to create the monitor | string | `true` | no | | questions_changing_extra_tags | Extra tags for GCP Cloud SQL Questions Changing monitor | list | `` | no | | questions_changing_message | Custom message for the Questions Changing monitor | string | `` | no | | questions_changing_seasonality | Seasonality of the algorithm | string | `weekly` | no | @@ -62,6 +65,7 @@ Creates DataDog monitors with the following checks: | questions_changing_threshold_critical_recovery | Questions Changing critical recovery threshold | string | `0.99` | no | | questions_changing_threshold_warning | Questions Changing warning threshold | string | `0.5` | no | | questions_changing_timeframe | Timeframe for the Questions Changing monitor | string | `last_1h` | no | +| replication_lag_enabled | Whether or not to create the monitor | string | `true` | no | | replication_lag_extra_tags | Extra tags for GCP Cloud SQL SQL Replication monitor | list | `` | no | | replication_lag_message | Custom message for the Replication Lag monitor | string | `` | no | | replication_lag_silenced | Groups to mute for GCP Cloud SQL Replication Lag monitor | map | `` | no | diff --git a/cloud/gcp/cloud-sql/mysql/inputs.tf b/cloud/gcp/cloud-sql/mysql/inputs.tf index a11bd26..e0f56c4 100644 --- a/cloud/gcp/cloud-sql/mysql/inputs.tf +++ b/cloud/gcp/cloud-sql/mysql/inputs.tf @@ -36,6 +36,12 @@ variable "project_id" { # # Network Connections # +variable "network_connections_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "network_connections_message" { description = "Custom message for the Network Connections monitor" type = "string" @@ -81,6 +87,12 @@ variable "network_connections_extra_tags" { # # Replication Lag # +variable "replication_lag_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "replication_lag_message" { description = "Custom message for the Replication Lag monitor" type = "string" @@ -120,6 +132,12 @@ variable "replication_lag_extra_tags" { # # Queries Changing Abnormally # +variable "queries_changing_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "queries_changing_database_ids" { description = "List of database ids for the Queries Changing monitor" type = "list" @@ -195,6 +213,12 @@ variable "queries_changing_extra_tags" { # # Questions Changing # +variable "questions_changing_enabled" { + description = "Whether or not to create the monitor" + type = "string" + default = "true" +} + variable "questions_changing_message" { description = "Custom message for the Questions Changing monitor" type = "string" diff --git a/cloud/gcp/cloud-sql/mysql/monitors-cloudsql-mysql.tf b/cloud/gcp/cloud-sql/mysql/monitors-cloudsql-mysql.tf index 0e988e2..7944ebc 100644 --- a/cloud/gcp/cloud-sql/mysql/monitors-cloudsql-mysql.tf +++ b/cloud/gcp/cloud-sql/mysql/monitors-cloudsql-mysql.tf @@ -15,6 +15,8 @@ data "template_file" "filter" { # MySQL Network Connections # resource "datadog_monitor" "network_connections" { + count = "${var.network_connections_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL MySQL Network Connections (hard limit: ${var.network_connections_hard_limit}) {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.network_connections_message, var.message)}" @@ -58,6 +60,8 @@ EOF # Replication Lag # resource "datadog_monitor" "replication_lag" { + count = "${var.replication_lag_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL MySQL Replication Lag {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" message = "${coalesce(var.replication_lag_message, var.message)}" @@ -104,6 +108,8 @@ EOF # Queries Anomaly # resource "datadog_monitor" "queries_changing_anomaly" { + count = "${var.queries_changing_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL MySQL Queries Count changed abnormally" message = "${coalesce(var.queries_changing_message, var.message)}" @@ -158,6 +164,8 @@ EOF # Questions Anomaly # resource "datadog_monitor" "questions_changing_anomaly" { + count = "${var.questions_changing_enabled} == true ? 1 : 0 " + name = "[${var.environment}] Cloud SQL MySQL Questions Count changed abnormally" message = "${coalesce(var.questions_changing_message, var.message)}"