From d76ebfc1c45347da562528a93d87731a8789e321 Mon Sep 17 00:00:00 2001 From: Rafael Romero Carmona Date: Thu, 14 Jun 2018 16:58:22 +0200 Subject: [PATCH] MON-224 Instance Memory Utilization alerts, including forecasts. --- cloud/gcp/cloud-sql/instance/README.md | 42 ++++++++++++++++++- .../instance/monitors-cloud-sql-instance.tf | 5 ++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/cloud/gcp/cloud-sql/instance/README.md b/cloud/gcp/cloud-sql/instance/README.md index 900c15a..b9d5ce5 100644 --- a/cloud/gcp/cloud-sql/instance/README.md +++ b/cloud/gcp/cloud-sql/instance/README.md @@ -1,5 +1,37 @@ +GCP CloudSQL Instance Monitors +============================== -## Inputs +How to use this module +---------------------- + +``` +module "datadog-monitors-gcp-cloudsql" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/gcp/clouds-sql/instance?ref={revision}" + + project_id = "${var.gcp_project_id}" + environment = "${var.environment}" + message = "${module.datadog-message-alerting.alerting-message}" +} + +``` + +Purpose +------- +Creates DataDog monitors with the following checks : + +* CloudSQL Instance CPU Utilization +* CloudSQL Instance Disk Utilization +* CloudSQL Instance Memory Utilization +* CloudSQL Instance Memory Utilization Forecast + +Useful links +------------ + +* [GCP Metrics for CloudSQL](https://cloud.google.com/monitoring/api/metrics_gcp#gcp-cloudsql) +* [Datadog Useful monitors for GCP CloudSQL](https://www.datadoghq.com/blog/monitor-google-cloud-sql/) + +Inputs +------ | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| @@ -18,11 +50,18 @@ | 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_forecast_history | History for the Memory Utilization Forecast monitor | string | `12h` | no | +| memory_forecast_history | History for the Memory Utilization Forecast monitor | string | `12h` | no | +| memory_forecast_interval | Interval for the Memory Utilization Forecast monitor | string | `30m` | no | | memory_forecast_interval | Interval for the Memory Utilization Forecast monitor | string | `30m` | no | | memory_forecast_message | Custom message for the Memory Utilization Forecast monitor | string | `` | no | +| memory_forecast_message | Custom message for the Memory Utilization Forecast monitor | string | `` | no | +| memory_forecast_silenced | Groups to mute for GCP Cloud SQL Memory Utilization Forecast monitor | map | `` | no | | memory_forecast_silenced | Groups to mute for GCP Cloud SQL Memory Utilization Forecast monitor | map | `` | no | | memory_forecast_threshold_critical | Memory Utilization Forecast in fraction (critical threshold) | string | `0.9` | no | +| memory_forecast_threshold_critical | Memory Utilization Forecast in fraction (critical threshold) | string | `0.9` | no | | memory_forecast_threshold_warning | Memory Utilization Forecast in fraction (warning threshold) | string | `0.8` | no | +| memory_forecast_threshold_warning | Memory Utilization Forecast in fraction (warning threshold) | string | `0.8` | no | +| memory_forecast_timeframe | Timeframe for the Memory Utilization Forecast monitor | string | `next_3d` | no | | memory_forecast_timeframe | Timeframe for the Memory Utilization Forecast monitor | string | `next_3d` | no | | memory_message | Custom message for the Memory Utilization monitor | string | `` | no | | memory_silenced | Groups to mute for GCP Cloud SQL Memory Utilization monitor | map | `` | no | @@ -31,4 +70,3 @@ | memory_timeframe | Timeframe for the Memory Utilization monitor | string | `last_5m` | no | | message | Message sent when a monitor is triggered | string | - | yes | | project_id | ID of the GCP Project | string | - | yes | - 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 69df62d..65deccc 100644 --- a/cloud/gcp/cloud-sql/instance/monitors-cloud-sql-instance.tf +++ b/cloud/gcp/cloud-sql/instance/monitors-cloud-sql-instance.tf @@ -6,7 +6,7 @@ data "template_file" "filter" { vars { filter = "${var.filter_tags_use_defaults == "true" ? - format("project_id:%s", var.project_id) : + format("project_id:%s", var.project_id) : "${var.filter_tags_custom}"}" } } @@ -133,6 +133,9 @@ EOF ] } +# +# Memory Utilization Forecast +# resource "datadog_monitor" "memory_utilization_forecast" { name = "[${var.environment}] Cloud SQL Memory Utilization Forecast {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.memory_forecast_message, var.message)}"