From 45054fd835f43ee7779f85654245f342d13ecc27 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Tue, 20 Mar 2018 16:05:29 +0100 Subject: [PATCH 01/33] MON-142: Monitor for MySQL --- databases/mysql/README.md | 41 ++++++++++++++++++++++ databases/mysql/inputs.tf | 45 ++++++++++++++++++++++++ databases/mysql/mon-mysql.tf | 67 ++++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+) create mode 100644 databases/mysql/README.md create mode 100644 databases/mysql/inputs.tf create mode 100644 databases/mysql/mon-mysql.tf diff --git a/databases/mysql/README.md b/databases/mysql/README.md new file mode 100644 index 0000000..ab67fd3 --- /dev/null +++ b/databases/mysql/README.md @@ -0,0 +1,41 @@ +MySQL DataDog monitors +========================================== + +How to use this module +---------------------- + +``` +module "datadog-monitors-mysql" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mysql?ref={revision}" + + environment = "${var.environment}" + message = "${module.datadog-message-alerting.alerting-message}" +} + +``` + +Purpose +------- +Creates DataDog monitors with the following checks : + +* MySQL Connections too high +* MySQL Number of threads too high + +Inputs +------ + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| delay | Delay in seconds for the metric evaluation | string | `900` | no | +| environment | Environment | string | - | yes | +| filter_tags | Tags used for custom filtering | string | `*` | no | +| mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | +| mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | +| mysql_thread_threshold_critical | Maximum critical acceptable percent of threads | string | `500` | no | +| mysql_thread_threshold_warning | Maximum warning acceptable percent of threads | string | `400` | no | +| message | Message sent when a monitor is triggered | string | - | yes | + +Related documentation +--------------------- + +DataDog documentation: [https://docs.datadoghq.com/integrations/mysql/](https://docs.datadoghq.com/integrations/mysql/) diff --git a/databases/mysql/inputs.tf b/databases/mysql/inputs.tf new file mode 100644 index 0000000..a751d76 --- /dev/null +++ b/databases/mysql/inputs.tf @@ -0,0 +1,45 @@ +variable "environment" { + description = "Environment" + type = "string" +} + +variable "filter_tags" { + description = "Tags used for filtering" + default = "*" +} + +variable "delay" { + default = 900 +} + +variable "message" { + description = "Message sent when a monitor is triggered" +} + +################################# +### MySQL connections ### +################################# + +variable "mysql_connection_threshold_critical" { + default = 80 + description = "Maximum critical acceptable percent of connections" +} + +variable "mysql_connection_threshold_warning" { + default = 70 + description = "Maximum warning acceptable percent of connections" +} + +################################# +### MySQL threads ### +################################# + +variable "mysql_thread_threshold_critical" { + default = 500 + description = "Maximum critical acceptable percent of threads" +} + +variable "mysql_thread_threshold_warning" { + default = 400 + description = "Maximum critical acceptable percent of threads" +} diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf new file mode 100644 index 0000000..725272b --- /dev/null +++ b/databases/mysql/mon-mysql.tf @@ -0,0 +1,67 @@ +resource "datadog_monitor" "mysql_cpu_80_15min" { + name = "[${var.environment}] Mysql Connections > {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" + message = "${var.message}" + type = "query alert" + + query = < ${var.mysql_connection_threshold_critical} + EOF + + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + + thresholds { + warning = "${var.mysql_connection_threshold_warning}" + critical = "${var.mysql_connection_threshold_critical}" + } + + notify_no_data = false # Will NOT notify when no data is received + evaluation_delay = "${var.delay}" + renotify_interval = 60 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + + tags = ["env:${var.environment}", "resource:mysql"] +} + + +resource "datadog_monitor" "mysql_thread_5min" { + name = "[${var.environment}] Mysql threads > {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" + message = "${var.message}" + type = "query alert" + + query = < ${var.mysql_thread_threshold_critical} + EOF + + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + + thresholds { + warning = "${var.mysql_thread_threshold_warning}" + critical = "${var.mysql_thread_threshold_critical}" + } + + notify_no_data = false # Will NOT notify when no data is received + evaluation_delay = "${var.delay}" + renotify_interval = 60 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + + tags = ["env:${var.environment}", "resource:mysql"] +} From 5bfa4206c1808774a70b2c11c8374557db52c760 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Tue, 20 Mar 2018 16:39:39 +0100 Subject: [PATCH 02/33] MON-142: Monitor for MySQL --- databases/mysql/mon-mysql.tf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 725272b..dc9a57a 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -1,7 +1,7 @@ resource "datadog_monitor" "mysql_cpu_80_15min" { name = "[${var.environment}] Mysql Connections > {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" message = "${var.message}" - type = "query alert" + type = "query alert" query = < Date: Tue, 20 Mar 2018 16:42:28 +0100 Subject: [PATCH 03/33] MON-142: Monitor for MySQL --- databases/mysql/mon-mysql.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index dc9a57a..957704a 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -18,7 +18,7 @@ resource "datadog_monitor" "mysql_cpu_80_15min" { critical = "${var.mysql_connection_threshold_critical}" } - notify_no_data = false # Will NOT notify when no data is received + notify_no_data = false # Will NOT notify when no data is received evaluation_delay = "${var.delay}" renotify_interval = 60 notify_audit = false @@ -52,7 +52,7 @@ resource "datadog_monitor" "mysql_thread_5min" { critical = "${var.mysql_thread_threshold_critical}" } - notify_no_data = false # Will NOT notify when no data is received + notify_no_data = false # Will NOT notify when no data is received evaluation_delay = "${var.delay}" renotify_interval = 60 notify_audit = false From bf327b6464322929b0b3d995825916b3d2246012 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 22 Mar 2018 09:54:06 +0100 Subject: [PATCH 04/33] MON-142: updated based on PR comments + best practices --- databases/mysql/README.md | 4 ++-- databases/mysql/inputs.tf | 28 ++++++++++++++++++---------- databases/mysql/mon-mysql.tf | 32 ++++++++++++++++++++------------ 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/databases/mysql/README.md b/databases/mysql/README.md index ab67fd3..5485210 100644 --- a/databases/mysql/README.md +++ b/databases/mysql/README.md @@ -31,8 +31,8 @@ Inputs | filter_tags | Tags used for custom filtering | string | `*` | no | | mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | -| mysql_thread_threshold_critical | Maximum critical acceptable percent of threads | string | `500` | no | -| mysql_thread_threshold_warning | Maximum warning acceptable percent of threads | string | `400` | no | +| mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | +| mysql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | | message | Message sent when a monitor is triggered | string | - | yes | Related documentation diff --git a/databases/mysql/inputs.tf b/databases/mysql/inputs.tf index a751d76..2c73edd 100644 --- a/databases/mysql/inputs.tf +++ b/databases/mysql/inputs.tf @@ -3,19 +3,27 @@ variable "environment" { type = "string" } -variable "filter_tags" { - description = "Tags used for filtering" - default = "*" -} - -variable "delay" { - default = 900 +# Global DataDog +variable "evaluation_delay" { + description = "Delay in seconds for the metric evaluation" + default = 900 } variable "message" { - description = "Message sent when a monitor is triggered" + description = "Message sent when an alert is triggered" } +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 = "*" +} + +# MySQL specific ################################# ### MySQL connections ### ################################# @@ -36,10 +44,10 @@ variable "mysql_connection_threshold_warning" { variable "mysql_thread_threshold_critical" { default = 500 - description = "Maximum critical acceptable percent of threads" + description = "Maximum critical acceptable number of threads" } variable "mysql_thread_threshold_warning" { default = 400 - description = "Maximum critical acceptable percent of threads" + description = "Maximum critical acceptable number of threads" } diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 957704a..67f9b3e 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -1,4 +1,12 @@ -resource "datadog_monitor" "mysql_cpu_80_15min" { +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_mysql:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + } +} + +resource "datadog_monitor" "mysql_connections_15min" { name = "[${var.environment}] Mysql Connections > {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" message = "${var.message}" type = "query alert" @@ -10,23 +18,23 @@ resource "datadog_monitor" "mysql_cpu_80_15min" { ) * 100 > ${var.mysql_connection_threshold_critical} EOF - evaluation_delay = "${var.delay}" - new_host_delay = "${var.delay}" + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.evaluation_delay}" thresholds { warning = "${var.mysql_connection_threshold_warning}" critical = "${var.mysql_connection_threshold_critical}" } - notify_no_data = false # Will NOT notify when no data is received - evaluation_delay = "${var.delay}" + notify_no_data = true + evaluation_delay = "${var.evaluation_delay}" renotify_interval = 60 notify_audit = false timeout_h = 0 include_tags = true - locked = false + locked = true require_full_window = true - new_host_delay = "${var.delay}" + new_host_delay = "${var.evaluation_delay}" no_data_timeframe = 20 tags = ["env:${var.environment}", "resource:mysql"] @@ -44,23 +52,23 @@ resource "datadog_monitor" "mysql_thread_5min" { ) > ${var.mysql_thread_threshold_critical} EOF - evaluation_delay = "${var.delay}" - new_host_delay = "${var.delay}" + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.evaluation_delay}" thresholds { warning = "${var.mysql_thread_threshold_warning}" critical = "${var.mysql_thread_threshold_critical}" } - notify_no_data = false # Will NOT notify when no data is received - evaluation_delay = "${var.delay}" + notify_no_data = true + evaluation_delay = "${var.evaluation_delay}" renotify_interval = 60 notify_audit = false timeout_h = 0 include_tags = true locked = false require_full_window = true - new_host_delay = "${var.delay}" + new_host_delay = "${var.evaluation_delay}" no_data_timeframe = 20 tags = ["env:${var.environment}", "resource:mysql"] From 2cbf052ce52bfe9bab8850e9a6f5ab4f96ed55e9 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 22 Mar 2018 09:56:23 +0100 Subject: [PATCH 05/33] MON-142: updated based on PR comments + best practices --- databases/mysql/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/databases/mysql/README.md b/databases/mysql/README.md index 5485210..882c1a1 100644 --- a/databases/mysql/README.md +++ b/databases/mysql/README.md @@ -28,7 +28,8 @@ Inputs |------|-------------|:----:|:-----:|:-----:| | delay | Delay in seconds for the metric evaluation | string | `900` | no | | environment | Environment | string | - | yes | -| filter_tags | Tags used for custom filtering | string | `*` | no | +| filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | +| filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | | mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | | mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | From 66aea6183bb39553f678b18cd470080c2f4fe3c0 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 22 Mar 2018 10:01:14 +0100 Subject: [PATCH 06/33] MON-142: updated based on PR comments + best practices --- databases/mysql/mon-mysql.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 67f9b3e..12a885f 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -13,8 +13,8 @@ resource "datadog_monitor" "mysql_connections_15min" { query = < ${var.mysql_connection_threshold_critical} EOF @@ -48,7 +48,7 @@ resource "datadog_monitor" "mysql_thread_5min" { query = < ${var.mysql_thread_threshold_critical} EOF From 6d406212aa6396129662869f09d4e789db10a718 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 22 Mar 2018 10:02:01 +0100 Subject: [PATCH 07/33] MON-142: updated based on PR comments + best practices --- databases/mysql/mon-mysql.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 12a885f..7146492 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -40,7 +40,6 @@ resource "datadog_monitor" "mysql_connections_15min" { tags = ["env:${var.environment}", "resource:mysql"] } - resource "datadog_monitor" "mysql_thread_5min" { name = "[${var.environment}] Mysql threads > {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" message = "${var.message}" From fcacc5198ffbef6ec9af39d4498b9c8834c8906f Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 22 Mar 2018 13:45:28 +0100 Subject: [PATCH 08/33] MON-142: filter is db_env --- databases/mysql/mon-mysql.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 7146492..aa4d90c 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -2,7 +2,7 @@ data "template_file" "filter" { template = "$${filter}" vars { - filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_mysql:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_mysql:enabled,db_env:%s", var.environment) : "${var.filter_tags_custom}"}" } } From d1c9b386080454b7d7b79ca7fb8637055bd96880 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Fri, 30 Mar 2018 15:50:10 +0200 Subject: [PATCH 09/33] MON-142: added group and updated values --- databases/mysql/mon-mysql.tf | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index aa4d90c..9ce75cc 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -13,8 +13,8 @@ resource "datadog_monitor" "mysql_connections_15min" { query = < ${var.mysql_connection_threshold_critical} EOF @@ -27,15 +27,10 @@ resource "datadog_monitor" "mysql_connections_15min" { } notify_no_data = true - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 60 - notify_audit = false + renotify_interval = 0 + require_full_window = false timeout_h = 0 include_tags = true - locked = true - require_full_window = true - new_host_delay = "${var.evaluation_delay}" - no_data_timeframe = 20 tags = ["env:${var.environment}", "resource:mysql"] } @@ -47,7 +42,7 @@ resource "datadog_monitor" "mysql_thread_5min" { query = < ${var.mysql_thread_threshold_critical} EOF @@ -60,15 +55,10 @@ resource "datadog_monitor" "mysql_thread_5min" { } notify_no_data = true - evaluation_delay = "${var.evaluation_delay}" - renotify_interval = 60 - notify_audit = false + renotify_interval = 0 + require_full_window = false timeout_h = 0 include_tags = true - locked = false - require_full_window = true - new_host_delay = "${var.evaluation_delay}" - no_data_timeframe = 20 tags = ["env:${var.environment}", "resource:mysql"] } From 8cf93046fb63784de8397ffe9e0ef4440480cbf7 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Tue, 3 Apr 2018 15:14:27 +0200 Subject: [PATCH 10/33] MON-142: updated monitors to latest best practices --- databases/mysql/README.md | 6 +++++- databases/mysql/mon-mysql.tf | 20 ++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/databases/mysql/README.md b/databases/mysql/README.md index 882c1a1..a111f3c 100644 --- a/databases/mysql/README.md +++ b/databases/mysql/README.md @@ -26,14 +26,18 @@ Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| delay | Delay in seconds for the metric evaluation | string | `900` | no | +| evaluation_delay | Delay in seconds for the metric evaluation | string | `900` | no | | environment | Environment | string | - | yes | | filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | | filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | | mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | +| mysql_connection_silenced | Groups to mute mysql connection monitor | map | `` | no | +| mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no | | mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | | mysql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | +| mysql_thread_silenced | Groups to mute mysql threads monitor | map | `` | no | +| mysql_thread_message | Custom message for MySQL thread monitor | string | `` | no | | message | Message sent when a monitor is triggered | string | - | yes | Related documentation diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 9ce75cc..0c8b752 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -6,10 +6,10 @@ data "template_file" "filter" { } } -resource "datadog_monitor" "mysql_connections_15min" { - name = "[${var.environment}] Mysql Connections > {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" - message = "${var.message}" - type = "query alert" +resource "datadog_monitor" "mysql_connection_too_high" { + name = "[${var.environment}] Mysql Connections {{comparator}} {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" + message = "${coalesce(var.mysql_connection_message, var.message)}" + type = "metric alert" query = < Date: Tue, 3 Apr 2018 15:24:22 +0200 Subject: [PATCH 11/33] MON-142: updated monitors to latest best practices --- databases/mysql/inputs.tf | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/databases/mysql/inputs.tf b/databases/mysql/inputs.tf index 2c73edd..b238bd3 100644 --- a/databases/mysql/inputs.tf +++ b/databases/mysql/inputs.tf @@ -38,6 +38,18 @@ variable "mysql_connection_threshold_warning" { description = "Maximum warning acceptable percent of connections" } +variable "mysql_connection_silenced" { + description = "Groups to mute mysql connection monitor" + type = "map" + default = {} +} + +variable "mysql_connection_message" { + description = "Custom message for MySQL connection monitor" + type = "string" + default = "" +} + ################################# ### MySQL threads ### ################################# @@ -51,3 +63,15 @@ variable "mysql_thread_threshold_warning" { default = 400 description = "Maximum critical acceptable number of threads" } + +variable "mysql_thread_silenced" { + description = "Groups to mute mysql threads monitor" + type = "map" + default = {} +} + +variable "mysql_thread_message" { + description = "Custom message for MySQL thread monitor" + type = "string" + default = "" +} From ec9245f92cfa7f5b34437e5e54e1a5ef12821607 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Wed, 18 Apr 2018 10:36:40 +0200 Subject: [PATCH 12/33] MON-142: Updated due to latest comments --- databases/mysql/README.md | 4 ++-- databases/mysql/inputs.tf | 2 +- databases/mysql/mon-mysql.tf | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/databases/mysql/README.md b/databases/mysql/README.md index a111f3c..b988d29 100644 --- a/databases/mysql/README.md +++ b/databases/mysql/README.md @@ -1,5 +1,5 @@ MySQL DataDog monitors -========================================== +====================== How to use this module ---------------------- @@ -26,7 +26,7 @@ Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| evaluation_delay | Delay in seconds for the metric evaluation | string | `900` | no | +| delay | Delay in seconds for the metric evaluation | string | `900` | no | | environment | Environment | string | - | yes | | filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | | filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | diff --git a/databases/mysql/inputs.tf b/databases/mysql/inputs.tf index b238bd3..3f1de5c 100644 --- a/databases/mysql/inputs.tf +++ b/databases/mysql/inputs.tf @@ -4,7 +4,7 @@ variable "environment" { } # Global DataDog -variable "evaluation_delay" { +variable "delay" { description = "Delay in seconds for the metric evaluation" default = 900 } diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 0c8b752..17900ed 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -7,7 +7,7 @@ data "template_file" "filter" { } resource "datadog_monitor" "mysql_connection_too_high" { - name = "[${var.environment}] Mysql Connections {{comparator}} {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" + name = "[${var.environment}] Mysql Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.mysql_connection_message, var.message)}" type = "metric alert" @@ -18,8 +18,8 @@ resource "datadog_monitor" "mysql_connection_too_high" { ) * 100 > ${var.mysql_connection_threshold_critical} EOF - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.evaluation_delay}" + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" thresholds { warning = "${var.mysql_connection_threshold_warning}" @@ -38,7 +38,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { } resource "datadog_monitor" "mysql_thread_too_high" { - name = "[${var.environment}] Mysql threads {{comparator}} {{#is_alert}}{{threshold}}%{{/is_alert}}{{#is_warning}}{{warn_threshold}}%{{/is_warning}} ({{value}}%)" + name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.mysql_thread_message, var.message)}" type = "metric alert" @@ -48,8 +48,8 @@ resource "datadog_monitor" "mysql_thread_too_high" { ) > ${var.mysql_thread_threshold_critical} EOF - evaluation_delay = "${var.evaluation_delay}" - new_host_delay = "${var.evaluation_delay}" + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" thresholds { warning = "${var.mysql_thread_threshold_warning}" From a6c8535e9912d76c7b503281195d985579eeb4a1 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Wed, 18 Apr 2018 11:15:32 +0200 Subject: [PATCH 13/33] MON-142: require_full_window should be set to true --- databases/mysql/mon-mysql.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 17900ed..4b7434d 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -28,7 +28,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { notify_no_data = true renotify_interval = 0 - require_full_window = false + require_full_window = true timeout_h = 0 include_tags = true @@ -58,7 +58,7 @@ resource "datadog_monitor" "mysql_thread_too_high" { notify_no_data = true renotify_interval = 0 - require_full_window = false + require_full_window = true timeout_h = 0 include_tags = true From f427e6e53fd1b76980799dba29fac7579da2bc72 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Wed, 18 Apr 2018 16:20:35 +0200 Subject: [PATCH 14/33] MON-142: changed host tag --- databases/mysql/mon-mysql.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 4b7434d..8a1f74d 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -13,8 +13,8 @@ resource "datadog_monitor" "mysql_connection_too_high" { query = < ${var.mysql_connection_threshold_critical} EOF @@ -44,7 +44,7 @@ resource "datadog_monitor" "mysql_thread_too_high" { query = < ${var.mysql_thread_threshold_critical} EOF From d6187750706c1fc8f864e6dd2271e1978a5f727f Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 19 Apr 2018 11:38:30 +0200 Subject: [PATCH 15/33] MON-142: typo in mysql threads and corrected mysql connection query --- databases/mysql/mon-mysql.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 8a1f74d..1458aac 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -14,7 +14,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { query = < ${var.mysql_connection_threshold_critical} EOF @@ -38,7 +38,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { } resource "datadog_monitor" "mysql_thread_too_high" { - name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" message = "${coalesce(var.mysql_thread_message, var.message)}" type = "metric alert" From aadbb096c5ac523931b257e93fe8f9ff93ba8194 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 19 Apr 2018 11:54:38 +0200 Subject: [PATCH 16/33] MON-142: typo --- databases/mysql/mon-mysql.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databases/mysql/mon-mysql.tf b/databases/mysql/mon-mysql.tf index 1458aac..3e9121a 100644 --- a/databases/mysql/mon-mysql.tf +++ b/databases/mysql/mon-mysql.tf @@ -38,7 +38,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { } resource "datadog_monitor" "mysql_thread_too_high" { - name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}" + name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" message = "${coalesce(var.mysql_thread_message, var.message)}" type = "metric alert" From 65260080660ddd33c14cf9587eac06ac11eca263 Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Thu, 19 Apr 2018 17:21:45 +0200 Subject: [PATCH 17/33] MON-142: decreased delay to 15s --- databases/mysql/README.md | 2 +- databases/mysql/inputs.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/databases/mysql/README.md b/databases/mysql/README.md index b988d29..ea48614 100644 --- a/databases/mysql/README.md +++ b/databases/mysql/README.md @@ -26,7 +26,7 @@ Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| delay | Delay in seconds for the metric evaluation | string | `900` | no | +| delay | Delay in seconds for the metric evaluation | string | `15` | no | | environment | Environment | string | - | yes | | filter_tags_use_defaults | Use default filter tags convention | string | `true` | no | | filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no | diff --git a/databases/mysql/inputs.tf b/databases/mysql/inputs.tf index 3f1de5c..e0648ba 100644 --- a/databases/mysql/inputs.tf +++ b/databases/mysql/inputs.tf @@ -6,7 +6,7 @@ variable "environment" { # Global DataDog variable "delay" { description = "Delay in seconds for the metric evaluation" - default = 900 + default = 15 } variable "message" { From 53224a9c20cb9a65e3263e9791a2f61182a10c7d Mon Sep 17 00:00:00 2001 From: Boris Rousseau Date: Mon, 23 Apr 2018 17:37:13 +0200 Subject: [PATCH 18/33] MON-142: typo in inputs --- databases/mysql/inputs.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databases/mysql/inputs.tf b/databases/mysql/inputs.tf index e0648ba..b3f8a08 100644 --- a/databases/mysql/inputs.tf +++ b/databases/mysql/inputs.tf @@ -61,7 +61,7 @@ variable "mysql_thread_threshold_critical" { variable "mysql_thread_threshold_warning" { default = 400 - description = "Maximum critical acceptable number of threads" + description = "Maximum warning acceptable number of threads" } variable "mysql_thread_silenced" { From cfcb3da1432b945f940b15b1ea54593d24f4217e Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Wed, 22 Aug 2018 14:25:16 +0200 Subject: [PATCH 19/33] MON-142 move mysql to right directory --- {databases => database}/mysql/README.md | 0 {databases => database}/mysql/inputs.tf | 0 {databases => database}/mysql/mon-mysql.tf | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {databases => database}/mysql/README.md (100%) rename {databases => database}/mysql/inputs.tf (100%) rename {databases => database}/mysql/mon-mysql.tf (100%) diff --git a/databases/mysql/README.md b/database/mysql/README.md similarity index 100% rename from databases/mysql/README.md rename to database/mysql/README.md diff --git a/databases/mysql/inputs.tf b/database/mysql/inputs.tf similarity index 100% rename from databases/mysql/inputs.tf rename to database/mysql/inputs.tf diff --git a/databases/mysql/mon-mysql.tf b/database/mysql/mon-mysql.tf similarity index 100% rename from databases/mysql/mon-mysql.tf rename to database/mysql/mon-mysql.tf From d42ba63d20bed2ca3500da10f8d21f38b11aac4a Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Wed, 22 Aug 2018 14:27:31 +0200 Subject: [PATCH 20/33] MON-142 auto update --- README.md | 1 + database/mysql/README.md | 44 ++++++++++--------- database/mysql/modules.tf | 8 ++++ .../mysql/{mon-mysql.tf => monitors-mysql.tf} | 0 database/mysql/outputs.tf | 9 ++++ 5 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 database/mysql/modules.tf rename database/mysql/{mon-mysql.tf => monitors-mysql.tf} (100%) create mode 100644 database/mysql/outputs.tf diff --git a/README.md b/README.md index ca132ec..60ed088 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi - [filter-tags](https://bitbucket.org/morea/terraform.feature.datadog/src/master/common/filter-tags/) - [database](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/) - [mongodb](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/mongodb/) + - [mysql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/mysql/) - [redis](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/redis/) - [middleware](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/) - [apache](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/apache/) diff --git a/database/mysql/README.md b/database/mysql/README.md index ea48614..d56cd43 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -1,44 +1,48 @@ -MySQL DataDog monitors -====================== +# DATABASE MYSQL DataDog monitors -How to use this module ----------------------- +## How to use this module ``` -module "datadog-monitors-mysql" { - source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mysql?ref={revision}" +module "datadog-monitors-database-mysql" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//database/mysql?ref={revision}" environment = "${var.environment}" - message = "${module.datadog-message-alerting.alerting-message}" + message = "${module.datadog-message-alerting.alerting-message}" } ``` -Purpose -------- -Creates DataDog monitors with the following checks : +## Purpose -* MySQL Connections too high -* MySQL Number of threads too high +Creates DataDog monitors with the following checks: -Inputs ------- +- Mysql Connections +- Mysql threads + +## Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| | delay | Delay in seconds for the metric evaluation | string | `15` | no | | environment | Environment | string | - | yes | -| filter_tags_use_defaults | Use default filter tags convention | string | `true` | 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 | +| message | Message sent when an alert is triggered | string | - | yes | +| mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no | +| mysql_connection_silenced | Groups to mute mysql connection monitor | map | `` | no | | mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | -| mysql_connection_silenced | Groups to mute mysql connection monitor | map | `` | no | -| mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no | +| mysql_thread_message | Custom message for MySQL thread monitor | string | `` | no | +| mysql_thread_silenced | Groups to mute mysql threads monitor | map | `` | no | | mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | | mysql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | -| mysql_thread_silenced | Groups to mute mysql threads monitor | map | `` | no | -| mysql_thread_message | Custom message for MySQL thread monitor | string | `` | no | -| message | Message sent when a monitor is triggered | string | - | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| mysql_connection_too_high_id | id for monitor mysql_connection_too_high | +| mysql_thread_too_high_id | id for monitor mysql_thread_too_high | Related documentation --------------------- diff --git a/database/mysql/modules.tf b/database/mysql/modules.tf new file mode 100644 index 0000000..a494121 --- /dev/null +++ b/database/mysql/modules.tf @@ -0,0 +1,8 @@ +module "filter-tags" { + source = "../../common/filter-tags" + + environment = "${var.environment}" + resource = "mysql" + filter_tags_use_defaults = "${var.filter_tags_use_defaults}" + filter_tags_custom = "${var.filter_tags_custom}" +} diff --git a/database/mysql/mon-mysql.tf b/database/mysql/monitors-mysql.tf similarity index 100% rename from database/mysql/mon-mysql.tf rename to database/mysql/monitors-mysql.tf diff --git a/database/mysql/outputs.tf b/database/mysql/outputs.tf new file mode 100644 index 0000000..c12fb69 --- /dev/null +++ b/database/mysql/outputs.tf @@ -0,0 +1,9 @@ +output "mysql_connection_too_high_id" { + description = "id for monitor mysql_connection_too_high" + value = "${datadog_monitor.mysql_connection_too_high.id}" +} + +output "mysql_thread_too_high_id" { + description = "id for monitor mysql_thread_too_high" + value = "${datadog_monitor.mysql_thread_too_high.id}" +} From 9af5a9ce97e161a1710d8b0cf1e47f153895620e Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Wed, 22 Aug 2018 14:28:44 +0200 Subject: [PATCH 21/33] MON-142 use filter tags module --- database/mysql/monitors-mysql.tf | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index 3e9121a..d35ef47 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -1,11 +1,3 @@ -data "template_file" "filter" { - template = "$${filter}" - - vars { - filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_mysql:enabled,db_env:%s", var.environment) : "${var.filter_tags_custom}"}" - } -} - resource "datadog_monitor" "mysql_connection_too_high" { name = "[${var.environment}] Mysql Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.mysql_connection_message, var.message)}" @@ -13,8 +5,8 @@ resource "datadog_monitor" "mysql_connection_too_high" { query = < ${var.mysql_connection_threshold_critical} EOF @@ -44,7 +36,7 @@ resource "datadog_monitor" "mysql_thread_too_high" { query = < ${var.mysql_thread_threshold_critical} EOF From 26f660310c0aef53f857ad8c47d1f91a37eba0d6 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Wed, 22 Aug 2018 15:06:48 +0200 Subject: [PATCH 22/33] MON-142 update tags for group --- database/mysql/monitors-mysql.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index d35ef47..c5c3aac 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -5,8 +5,8 @@ resource "datadog_monitor" "mysql_connection_too_high" { query = < ${var.mysql_connection_threshold_critical} EOF @@ -36,7 +36,7 @@ resource "datadog_monitor" "mysql_thread_too_high" { query = < ${var.mysql_thread_threshold_critical} EOF From e7c21f49aba289a90301108ce955979dd8c1eeb3 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Wed, 22 Aug 2018 15:07:06 +0200 Subject: [PATCH 23/33] MON-142 split delay variable --- database/mysql/README.md | 3 ++- database/mysql/inputs.tf | 8 ++++++-- database/mysql/monitors-mysql.tf | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/database/mysql/README.md b/database/mysql/README.md index d56cd43..05d8d16 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -23,8 +23,8 @@ Creates DataDog monitors with the following checks: | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| delay | Delay in seconds for the metric evaluation | string | `15` | no | | environment | Environment | string | - | yes | +| evaluation_delay | Delay in seconds for the metric evaluation | string | `15` | 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 | | message | Message sent when an alert is triggered | string | - | yes | @@ -36,6 +36,7 @@ Creates DataDog monitors with the following checks: | mysql_thread_silenced | Groups to mute mysql threads monitor | map | `` | no | | mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | | mysql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | +| new_host_delay | Delay in seconds for the metric evaluation | string | `300` | no | ## Outputs diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index b3f8a08..9a417c3 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -3,12 +3,16 @@ variable "environment" { type = "string" } -# Global DataDog -variable "delay" { +variable "evaluation_delay" { description = "Delay in seconds for the metric evaluation" default = 15 } +variable "new_host_delay" { + description = "Delay in seconds for the metric evaluation" + default = 300 +} + variable "message" { description = "Message sent when an alert is triggered" } diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index c5c3aac..4ba9196 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -10,8 +10,8 @@ resource "datadog_monitor" "mysql_connection_too_high" { ) * 100 > ${var.mysql_connection_threshold_critical} EOF - evaluation_delay = "${var.delay}" - new_host_delay = "${var.delay}" + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" thresholds { warning = "${var.mysql_connection_threshold_warning}" @@ -40,8 +40,8 @@ resource "datadog_monitor" "mysql_thread_too_high" { ) > ${var.mysql_thread_threshold_critical} EOF - evaluation_delay = "${var.delay}" - new_host_delay = "${var.delay}" + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" thresholds { warning = "${var.mysql_thread_threshold_warning}" From f8ea23eaf4f3fff9318431b5d827c1a3279dc154 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Wed, 22 Aug 2018 18:05:59 +0200 Subject: [PATCH 24/33] MON-142 add extra tags --- database/mysql/README.md | 2 ++ database/mysql/inputs.tf | 12 ++++++++++++ database/mysql/monitors-mysql.tf | 8 ++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/database/mysql/README.md b/database/mysql/README.md index 05d8d16..8728aaf 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -28,10 +28,12 @@ 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 an alert is triggered | string | - | yes | +| mysql_connection_extra_tags | Extra tags for MySQL connection monitor | list | `` | no | | mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no | | mysql_connection_silenced | Groups to mute mysql connection monitor | map | `` | no | | mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | +| mysql_thread_extra_tags | Extra tags for MySQL thread monitor | list | `` | no | | mysql_thread_message | Custom message for MySQL thread monitor | string | `` | no | | mysql_thread_silenced | Groups to mute mysql threads monitor | map | `` | no | | mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index 9a417c3..35ed6df 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -54,6 +54,12 @@ variable "mysql_connection_message" { default = "" } +variable "mysql_connection_extra_tags" { + description = "Extra tags for MySQL connection monitor" + type = "list" + default = [] +} + ################################# ### MySQL threads ### ################################# @@ -79,3 +85,9 @@ variable "mysql_thread_message" { type = "string" default = "" } + +variable "mysql_thread_extra_tags" { + description = "Extra tags for MySQL thread monitor" + type = "list" + default = [] +} diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index 4ba9196..5eae56f 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -18,7 +18,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { critical = "${var.mysql_connection_threshold_critical}" } - notify_no_data = true + notify_no_data = false renotify_interval = 0 require_full_window = true timeout_h = 0 @@ -26,7 +26,7 @@ resource "datadog_monitor" "mysql_connection_too_high" { silenced = "${var.mysql_connection_silenced}" - tags = ["env:${var.environment}", "resource:mysql"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"] } resource "datadog_monitor" "mysql_thread_too_high" { @@ -48,7 +48,7 @@ resource "datadog_monitor" "mysql_thread_too_high" { critical = "${var.mysql_thread_threshold_critical}" } - notify_no_data = true + notify_no_data = false renotify_interval = 0 require_full_window = true timeout_h = 0 @@ -56,5 +56,5 @@ resource "datadog_monitor" "mysql_thread_too_high" { silenced = "${var.mysql_thread_silenced}" - tags = ["env:${var.environment}", "resource:mysql"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_thread_extra_tags}"] } From 0e22a0548937a0385cbe2996d5de00f6bc8b2a78 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 16:50:49 +0200 Subject: [PATCH 25/33] MON-142 add some monitors for mysql --- database/mysql/inputs.tf | 370 ++++++++++++++++++++++++++++++- database/mysql/monitors-mysql.tf | 227 ++++++++++++++++++- 2 files changed, 574 insertions(+), 23 deletions(-) diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index 35ed6df..0b150c9 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -28,6 +28,36 @@ variable "filter_tags_custom" { } # MySQL specific + +################################# +### MySQL availability ### +################################# + +variable "mysql_availability_silenced" { + description = "Groups to mute for Mysql availability monitor" + type = "map" + default = {} +} + +variable "mysql_availability_extra_tags" { + description = "Extra tags for Mysql availability monitor" + type = "list" + default = [] +} + +variable "mysql_availability_message" { + description = "Custom message for Mysql availability monitor" + type = "string" + default = "" +} + +variable "mysql_availability_threshold_critical" { + description = "Nginx status monitor (critical threshold)" + type = "string" + default = 1.1754943508222875e-38 +} + + ################################# ### MySQL connections ### ################################# @@ -42,8 +72,20 @@ variable "mysql_connection_threshold_warning" { description = "Maximum warning acceptable percent of connections" } +variable "mysql_connection_time_aggregator" { + description = "Monitor time aggregator for MySQL connection monitor [available values: min, max or avg]" + type = "string" + default = "avg" +} + +variable "mysql_connection_timeframe" { + description = "Monitor timeframe for MySQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_10m" +} + variable "mysql_connection_silenced" { - description = "Groups to mute mysql connection monitor" + description = "Groups to mute MySQL connection monitor" type = "map" default = {} } @@ -60,34 +102,340 @@ variable "mysql_connection_extra_tags" { default = [] } +################################# +### MySQL aborted connects ### +################################# + +variable "mysql_aborted_threshold_critical" { + default = 10 + description = "Maximum critical acceptable percent of aborted connects" +} + +variable "mysql_aborted_threshold_warning" { + default = 5 + description = "Maximum warning acceptable percent of aborted connects" +} + +variable "mysql_aborted_time_aggregator" { + description = "Monitor time aggregator for MySQL aborted connects monitor [available values: min, max or avg]" + type = "string" + default = "avg" +} + +variable "mysql_aborted_timeframe" { + description = "Monitor timeframe for MySQL aborted connects monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_10m" +} + +variable "mysql_aborted_silenced" { + description = "Groups to mute MySQL aborted connects monitor" + type = "map" + default = {} +} + +variable "mysql_aborted_message" { + description = "Custom message for MySQL aborted connects monitor" + type = "string" + default = "" +} + +variable "mysql_aborted_extra_tags" { + description = "Extra tags for MySQL aborted connects monitor" + type = "list" + default = [] +} + +################################# +### MySQL slow queries ### +################################# + +variable "mysql_slow_threshold_critical" { + default = 20 + description = "Maximum critical acceptable percent of slow queries" +} + +variable "mysql_slow_threshold_warning" { + default = 5 + description = "Maximum warning acceptable percent of slow queries" +} + +variable "mysql_slow_time_aggregator" { + description = "Monitor time aggregator for MySQL slow queries monitor [available values: min, max or avg]" + type = "string" + default = "avg" +} + +variable "mysql_slow_timeframe" { + description = "Monitor timeframe for MySQL slow queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_15m" +} + +variable "mysql_slow_silenced" { + description = "Groups to mute MySQL slow queries monitor" + type = "map" + default = {} +} + +variable "mysql_slow_message" { + description = "Custom message for MySQL slow queries monitor" + type = "string" + default = "" +} + +variable "mysql_slow_extra_tags" { + description = "Extra tags for MySQL slow queries monitor" + type = "list" + default = [] +} + +################################# +# MySQL innodb pool efficiency # +################################# + +variable "mysql_pool_efficiency_threshold_critical" { + default = 20 + description = "Maximum critical acceptable percent of innodb buffer pool efficiency" +} + +variable "mysql_pool_efficiency_threshold_warning" { + default = 1 + description = "Maximum warning acceptable percent of innodb buffer pool efficiency" +} + +variable "mysql_pool_efficiency_time_aggregator" { + description = "Monitor time aggregator for MySQL innodb buffer pool efficiency monitor [available values: min, max or avg]" + type = "string" + default = "sum" +} + +variable "mysql_pool_efficiency_timeframe" { + description = "Monitor timeframe for MySQL innodb buffer pool efficiency monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1h" +} + +variable "mysql_pool_efficiency_silenced" { + description = "Groups to mute MySQL innodb buffer pool efficiency monitor" + type = "map" + default = {} +} + +variable "mysql_pool_efficiency_message" { + description = "Custom message for MySQL innodb buffer pool efficiency monitor" + type = "string" + default = "" +} + +variable "mysql_pool_efficiency_extra_tags" { + description = "Extra tags for MySQL innodb buffer pool efficiency monitor" + type = "list" + default = [] +} + +################################# +# MySQL innodb pool utilization # +################################# + +variable "mysql_pool_utilization_threshold_critical" { + default = 90 + description = "Maximum critical acceptable percent of innodb buffer pool utilization" +} + +variable "mysql_pool_utilization_threshold_warning" { + default = 75 + description = "Maximum warning acceptable percent of innodb buffer pool utilization" +} + +variable "mysql_pool_utilization_time_aggregator" { + description = "Monitor time aggregator for MySQL innodb buffer pool utilization monitor [available values: min, max or avg]" + type = "string" + default = "min" +} + +variable "mysql_pool_utilization_timeframe" { + description = "Monitor timeframe for MySQL innodb buffer pool utilization monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_4h" +} + +variable "mysql_pool_utilization_silenced" { + description = "Groups to mute MySQL innodb buffer pool utilization monitor" + type = "map" + default = {} +} + +variable "mysql_pool_utilization_message" { + description = "Custom message for MySQL innodb buffer pool utilization monitor" + type = "string" + default = "" +} + +variable "mysql_pool_utilization_extra_tags" { + description = "Extra tags for MySQL innodb buffer pool utilization monitor" + type = "list" + default = [] +} + ################################# ### MySQL threads ### ################################# -variable "mysql_thread_threshold_critical" { - default = 500 +variable "mysql_threads_threshold_critical" { + default = 1 description = "Maximum critical acceptable number of threads" } -variable "mysql_thread_threshold_warning" { - default = 400 - description = "Maximum warning acceptable number of threads" +variable "mysql_threads_detection_algorithm" { + description = "Anomaly Detection Algorithm used" + type = "string" + default = "basic" } -variable "mysql_thread_silenced" { +variable "mysql_threads_deviations" { + description = "Deviations to detect the anomaly" + type = "string" + default = 2 +} + +variable "mysql_threads_direction" { + description = "Direction of the anomaly. It can be both, below or above." + type = "string" + default = "above" +} + +variable "mysql_threads_alert_window" { + description = "Alert window." + type = "string" + default = "last_15m" +} + +variable "mysql_threads_interval" { + description = "Interval." + type = "string" + default = 60 +} + +variable "mysql_threads_count_default_zero" { + description = "Count default zero." + type = "string" + default = "true" +} + +variable "mysql_threads_seasonality" { + description = "Seasonality of the algorithm" + type = "string" + default = "daily" +} + +variable "mysql_threads_time_aggregator" { + description = "Monitor time aggregator for MySQL threads monitor [available values: min, max or avg]" + type = "string" + default = "avg" +} + +variable "mysql_threads_timeframe" { + description = "Monitor timeframe for MySQL threads monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_4h" +} + +variable "mysql_threads_silenced" { description = "Groups to mute mysql threads monitor" type = "map" default = {} } -variable "mysql_thread_message" { - description = "Custom message for MySQL thread monitor" +variable "mysql_threads_message" { + description = "Custom message for MySQL threads monitor" type = "string" default = "" } -variable "mysql_thread_extra_tags" { - description = "Extra tags for MySQL thread monitor" +variable "mysql_threads_extra_tags" { + description = "Extra tags for MySQL threads monitor" + type = "list" + default = [] +} + +################################# +### MySQL queries ### +################################# + +variable "mysql_queries_threshold_critical" { + default = 1 + description = "Maximum critical acceptable number of queries" +} + +variable "mysql_queries_detection_algorithm" { + description = "Anomaly Detection Algorithm used" + type = "string" + default = "agile" +} + +variable "mysql_queries_deviations" { + description = "Deviations to detect the anomaly" + type = "string" + default = 2 +} + +variable "mysql_queries_direction" { + description = "Direction of the anomaly. It can be both, below or above." + type = "string" + default = "both" +} + +variable "mysql_queries_alert_window" { + description = "Alert window." + type = "string" + default = "last_15m" +} + +variable "mysql_queries_interval" { + description = "Interval." + type = "string" + default = 60 +} + +variable "mysql_queries_count_default_zero" { + description = "Count default zero." + type = "string" + default = "true" +} + +variable "mysql_queries_seasonality" { + description = "Seasonality of the algorithm" + type = "string" + default = "daily" +} + +variable "mysql_queries_time_aggregator" { + description = "Monitor time aggregator for MySQL queries monitor [available values: min, max or avg]" + type = "string" + default = "avg" +} + +variable "mysql_queries_timeframe" { + description = "Monitor timeframe for MySQL queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_4h" +} + +variable "mysql_queries_silenced" { + description = "Groups to mute mysql queries monitor" + type = "map" + default = {} +} + +variable "mysql_queries_message" { + description = "Custom message for MySQL queries monitor" + type = "string" + default = "" +} + +variable "mysql_queries_extra_tags" { + description = "Extra tags for MySQL queries monitor" type = "list" default = [] } diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index 5eae56f..acd8d42 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -1,10 +1,40 @@ -resource "datadog_monitor" "mysql_connection_too_high" { +resource "datadog_monitor" "mysql_availability" { + name = "[${var.environment}] Mysql server does not respond" + message = "${coalesce(var.mysql_availability_message, var.message)}" + + type = "service check" + + query = < ${var.mysql_connection_threshold_critical} @@ -29,23 +59,24 @@ resource "datadog_monitor" "mysql_connection_too_high" { tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"] } -resource "datadog_monitor" "mysql_thread_too_high" { - name = "[${var.environment}] Mysql threads {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" - message = "${coalesce(var.mysql_thread_message, var.message)}" +resource "datadog_monitor" "mysql_aborted" { + name = "[${var.environment}] Mysql Aborted connects {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = "${coalesce(var.mysql_aborted_message, var.message)}" type = "metric alert" query = < ${var.mysql_thread_threshold_critical} + ${var.mysql_aborted_time_aggregator}(${var.mysql_aborted_timeframe}): ( + avg:mysql.net.aborted_connects${module.filter-tags.query_alert} by {server} / + avg:mysql.performance.queries_connected${module.filter-tags.query_alert} by {server} + ) * 100 > ${var.mysql_aborted_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" new_host_delay = "${var.new_host_delay}" thresholds { - warning = "${var.mysql_thread_threshold_warning}" - critical = "${var.mysql_thread_threshold_critical}" + warning = "${var.mysql_aborted_threshold_warning}" + critical = "${var.mysql_aborted_threshold_critical}" } notify_no_data = false @@ -54,7 +85,179 @@ resource "datadog_monitor" "mysql_thread_too_high" { timeout_h = 0 include_tags = true - silenced = "${var.mysql_thread_silenced}" + silenced = "${var.mysql_aborted_silenced}" - tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_thread_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_aborted_extra_tags}"] } + +resource "datadog_monitor" "mysql_slow" { + name = "[${var.environment}] Mysql Slow queries {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + message = "${coalesce(var.mysql_slow_message, var.message)}" + type = "metric alert" + + query = < ${var.mysql_slow_threshold_critical} + EOF + + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" + + thresholds { + warning = "${var.mysql_slow_threshold_warning}" + critical = "${var.mysql_slow_threshold_critical}" + } + + notify_no_data = false + renotify_interval = 0 + require_full_window = true + timeout_h = 0 + include_tags = true + + silenced = "${var.mysql_slow_silenced}" + + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_slow_extra_tags}"] +} + +resource "datadog_monitor" "mysql_pool_efficiency" { + name = "[${var.environment}] Mysql Innodb buffer pool efficiency {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = "${coalesce(var.mysql_pool_efficiency_message, var.message)}" + type = "metric alert" + + query = < ${var.mysql_pool_efficiency_threshold_critical} + EOF + + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" + + thresholds { + warning = "${var.mysql_pool_efficiency_threshold_warning}" + critical = "${var.mysql_pool_efficiency_threshold_critical}" + } + + notify_no_data = false + renotify_interval = 0 + require_full_window = true + timeout_h = 0 + include_tags = true + + silenced = "${var.mysql_pool_efficiency_silenced}" + + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_efficiency_extra_tags}"] +} + +resource "datadog_monitor" "mysql_pool_utilization" { + name = "[${var.environment}] Mysql Innodb buffer pool utilization {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = "${coalesce(var.mysql_pool_utilization_message, var.message)}" + type = "metric alert" + + query = < ${var.mysql_pool_utilization_threshold_critical} + EOF + + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" + + thresholds { + warning = "${var.mysql_pool_utilization_threshold_warning}" + critical = "${var.mysql_pool_utilization_threshold_critical}" + } + + notify_no_data = false + renotify_interval = 0 + require_full_window = true + timeout_h = 0 + include_tags = true + + silenced = "${var.mysql_pool_utilization_silenced}" + + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_utilization_extra_tags}"] +} + +resource "datadog_monitor" "mysql_threads_anomaly" { + name = "[${var.environment}] Mysql threads changed abnormally" + message = "${coalesce(var.mysql_threads_message, var.message)}" + type = "metric alert" + + query = <= ${var.mysql_threads_threshold_critical} + EOF + + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" + + thresholds { + critical = "${var.mysql_threads_threshold_critical}" + critical_recovery = 0 + } + + notify_no_data = false + renotify_interval = 0 + require_full_window = true + timeout_h = 0 + include_tags = true + + silenced = "${var.mysql_threads_silenced}" + + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_threads_extra_tags}"] +} + +resource "datadog_monitor" "mysql_queries_anomaly" { + name = "[${var.environment}] Mysql queries changed abnormally" + message = "${coalesce(var.mysql_queries_message, var.message)}" + type = "metric alert" + + query = <= ${var.mysql_queries_threshold_critical} + EOF + + evaluation_delay = "${var.evaluation_delay}" + new_host_delay = "${var.new_host_delay}" + + thresholds { + critical = "${var.mysql_queries_threshold_critical}" + critical_recovery = 0 + } + + notify_no_data = false + renotify_interval = 0 + require_full_window = true + timeout_h = 0 + include_tags = true + + silenced = "${var.mysql_queries_silenced}" + + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_queries_extra_tags}"] +} \ No newline at end of file From 83ceaad43a47fb273009780b79ec9278a8cb6c4f Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 16:52:40 +0200 Subject: [PATCH 26/33] MON-142 auto update --- database/mysql/README.md | 85 ++++++++++++++++++++++++++++---- database/mysql/inputs.tf | 1 - database/mysql/monitors-mysql.tf | 7 ++- database/mysql/outputs.tf | 42 +++++++++++++--- 4 files changed, 115 insertions(+), 20 deletions(-) diff --git a/database/mysql/README.md b/database/mysql/README.md index 8728aaf..73f60e1 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -16,8 +16,14 @@ module "datadog-monitors-database-mysql" { Creates DataDog monitors with the following checks: +- Mysql server does not respond - Mysql Connections -- Mysql threads +- Mysql Aborted connects +- Mysql Slow queries +- Mysql Innodb buffer pool efficiency +- Mysql Innodb buffer pool utilization +- Mysql threads changed abnormally +- Mysql queries changed abnormally ## Inputs @@ -28,24 +34,85 @@ 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 an alert is triggered | string | - | yes | +| mysql_aborted_extra_tags | Extra tags for MySQL aborted connects monitor | list | `` | no | +| mysql_aborted_message | Custom message for MySQL aborted connects monitor | string | `` | no | +| mysql_aborted_silenced | Groups to mute MySQL aborted connects monitor | map | `` | no | +| mysql_aborted_threshold_critical | Maximum critical acceptable percent of aborted connects | string | `10` | no | +| mysql_aborted_threshold_warning | Maximum warning acceptable percent of aborted connects | string | `5` | no | +| mysql_aborted_time_aggregator | Monitor time aggregator for MySQL aborted connects monitor [available values: min, max or avg] | string | `avg` | no | +| mysql_aborted_timeframe | Monitor timeframe for MySQL aborted connects monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_10m` | no | +| mysql_availability_extra_tags | Extra tags for Mysql availability monitor | list | `` | no | +| mysql_availability_message | Custom message for Mysql availability monitor | string | `` | no | +| mysql_availability_silenced | Groups to mute for Mysql availability monitor | map | `` | no | +| mysql_availability_threshold_critical | Nginx status monitor (critical threshold) | string | `1.1754943508222875e-38` | no | | mysql_connection_extra_tags | Extra tags for MySQL connection monitor | list | `` | no | | mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no | -| mysql_connection_silenced | Groups to mute mysql connection monitor | map | `` | no | +| mysql_connection_silenced | Groups to mute MySQL connection monitor | map | `` | no | | mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no | | mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no | -| mysql_thread_extra_tags | Extra tags for MySQL thread monitor | list | `` | no | -| mysql_thread_message | Custom message for MySQL thread monitor | string | `` | no | -| mysql_thread_silenced | Groups to mute mysql threads monitor | map | `` | no | -| mysql_thread_threshold_critical | Maximum critical acceptable number of threads | string | `500` | no | -| mysql_thread_threshold_warning | Maximum warning acceptable number of threads | string | `400` | no | +| mysql_connection_time_aggregator | Monitor time aggregator for MySQL connection monitor [available values: min, max or avg] | string | `avg` | no | +| mysql_connection_timeframe | Monitor timeframe for MySQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_10m` | no | +| mysql_pool_efficiency_extra_tags | Extra tags for MySQL innodb buffer pool efficiency monitor | list | `` | no | +| mysql_pool_efficiency_message | Custom message for MySQL innodb buffer pool efficiency monitor | string | `` | no | +| mysql_pool_efficiency_silenced | Groups to mute MySQL innodb buffer pool efficiency monitor | map | `` | no | +| mysql_pool_efficiency_threshold_critical | Maximum critical acceptable percent of innodb buffer pool efficiency | string | `20` | no | +| mysql_pool_efficiency_threshold_warning | Maximum warning acceptable percent of innodb buffer pool efficiency | string | `1` | no | +| mysql_pool_efficiency_time_aggregator | Monitor time aggregator for MySQL innodb buffer pool efficiency monitor [available values: min, max or avg] | string | `sum` | no | +| mysql_pool_efficiency_timeframe | Monitor timeframe for MySQL innodb buffer pool efficiency monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_1h` | no | +| mysql_pool_utilization_extra_tags | Extra tags for MySQL innodb buffer pool utilization monitor | list | `` | no | +| mysql_pool_utilization_message | Custom message for MySQL innodb buffer pool utilization monitor | string | `` | no | +| mysql_pool_utilization_silenced | Groups to mute MySQL innodb buffer pool utilization monitor | map | `` | no | +| mysql_pool_utilization_threshold_critical | Maximum critical acceptable percent of innodb buffer pool utilization | string | `90` | no | +| mysql_pool_utilization_threshold_warning | Maximum warning acceptable percent of innodb buffer pool utilization | string | `75` | no | +| mysql_pool_utilization_time_aggregator | Monitor time aggregator for MySQL innodb buffer pool utilization monitor [available values: min, max or avg] | string | `min` | no | +| mysql_pool_utilization_timeframe | Monitor timeframe for MySQL innodb buffer pool utilization monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_4h` | no | +| mysql_queries_alert_window | Alert window. | string | `last_15m` | no | +| mysql_queries_count_default_zero | Count default zero. | string | `true` | no | +| mysql_queries_detection_algorithm | Anomaly Detection Algorithm used | string | `agile` | no | +| mysql_queries_deviations | Deviations to detect the anomaly | string | `2` | no | +| mysql_queries_direction | Direction of the anomaly. It can be both, below or above. | string | `both` | no | +| mysql_queries_extra_tags | Extra tags for MySQL queries monitor | list | `` | no | +| mysql_queries_interval | Interval. | string | `60` | no | +| mysql_queries_message | Custom message for MySQL queries monitor | string | `` | no | +| mysql_queries_seasonality | Seasonality of the algorithm | string | `daily` | no | +| mysql_queries_silenced | Groups to mute mysql queries monitor | map | `` | no | +| mysql_queries_threshold_critical | Maximum critical acceptable number of queries | string | `1` | no | +| mysql_queries_time_aggregator | Monitor time aggregator for MySQL queries monitor [available values: min, max or avg] | string | `avg` | no | +| mysql_queries_timeframe | Monitor timeframe for MySQL queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_4h` | no | +| mysql_slow_extra_tags | Extra tags for MySQL slow queries monitor | list | `` | no | +| mysql_slow_message | Custom message for MySQL slow queries monitor | string | `` | no | +| mysql_slow_silenced | Groups to mute MySQL slow queries monitor | map | `` | no | +| mysql_slow_threshold_critical | Maximum critical acceptable percent of slow queries | string | `20` | no | +| mysql_slow_threshold_warning | Maximum warning acceptable percent of slow queries | string | `5` | no | +| mysql_slow_time_aggregator | Monitor time aggregator for MySQL slow queries monitor [available values: min, max or avg] | string | `avg` | no | +| mysql_slow_timeframe | Monitor timeframe for MySQL slow queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | +| mysql_threads_alert_window | Alert window. | string | `last_15m` | no | +| mysql_threads_count_default_zero | Count default zero. | string | `true` | no | +| mysql_threads_detection_algorithm | Anomaly Detection Algorithm used | string | `basic` | no | +| mysql_threads_deviations | Deviations to detect the anomaly | string | `2` | no | +| mysql_threads_direction | Direction of the anomaly. It can be both, below or above. | string | `above` | no | +| mysql_threads_extra_tags | Extra tags for MySQL threads monitor | list | `` | no | +| mysql_threads_interval | Interval. | string | `60` | no | +| mysql_threads_message | Custom message for MySQL threads monitor | string | `` | no | +| mysql_threads_seasonality | Seasonality of the algorithm | string | `daily` | no | +| mysql_threads_silenced | Groups to mute mysql threads monitor | map | `` | no | +| mysql_threads_threshold_critical | Maximum critical acceptable number of threads | string | `1` | no | +| mysql_threads_time_aggregator | Monitor time aggregator for MySQL threads monitor [available values: min, max or avg] | string | `avg` | no | +| mysql_threads_timeframe | Monitor timeframe for MySQL threads monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_4h` | no | | new_host_delay | Delay in seconds for the metric evaluation | string | `300` | no | ## Outputs | Name | Description | |------|-------------| -| mysql_connection_too_high_id | id for monitor mysql_connection_too_high | -| mysql_thread_too_high_id | id for monitor mysql_thread_too_high | +| mysql_aborted_id | id for monitor mysql_aborted | +| mysql_availability_id | id for monitor mysql_availability | +| mysql_connection_id | id for monitor mysql_connection | +| mysql_pool_efficiency_id | id for monitor mysql_pool_efficiency | +| mysql_pool_utilization_id | id for monitor mysql_pool_utilization | +| mysql_queries_anomaly_id | id for monitor mysql_queries_anomaly | +| mysql_slow_id | id for monitor mysql_slow | +| mysql_threads_anomaly_id | id for monitor mysql_threads_anomaly | Related documentation --------------------- diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index 0b150c9..35944ee 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -57,7 +57,6 @@ variable "mysql_availability_threshold_critical" { default = 1.1754943508222875e-38 } - ################################# ### MySQL connections ### ################################# diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index acd8d42..03404ca 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -27,7 +27,6 @@ resource "datadog_monitor" "mysql_availability" { tags = ["env:${var.environment}", "type:middleware", "provider:php-fpm", "resource:php-fpm", "team:claranet", "created-by:terraform", "${var.mysql_availability_extra_tags}"] } - resource "datadog_monitor" "mysql_connection" { name = "[${var.environment}] Mysql Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.mysql_connection_message, var.message)}" @@ -208,7 +207,7 @@ resource "datadog_monitor" "mysql_threads_anomaly" { new_host_delay = "${var.new_host_delay}" thresholds { - critical = "${var.mysql_threads_threshold_critical}" + critical = "${var.mysql_threads_threshold_critical}" critical_recovery = 0 } @@ -247,7 +246,7 @@ resource "datadog_monitor" "mysql_queries_anomaly" { new_host_delay = "${var.new_host_delay}" thresholds { - critical = "${var.mysql_queries_threshold_critical}" + critical = "${var.mysql_queries_threshold_critical}" critical_recovery = 0 } @@ -260,4 +259,4 @@ resource "datadog_monitor" "mysql_queries_anomaly" { silenced = "${var.mysql_queries_silenced}" tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_queries_extra_tags}"] -} \ No newline at end of file +} diff --git a/database/mysql/outputs.tf b/database/mysql/outputs.tf index c12fb69..143b534 100644 --- a/database/mysql/outputs.tf +++ b/database/mysql/outputs.tf @@ -1,9 +1,39 @@ -output "mysql_connection_too_high_id" { - description = "id for monitor mysql_connection_too_high" - value = "${datadog_monitor.mysql_connection_too_high.id}" +output "mysql_availability_id" { + description = "id for monitor mysql_availability" + value = "${datadog_monitor.mysql_availability.id}" } -output "mysql_thread_too_high_id" { - description = "id for monitor mysql_thread_too_high" - value = "${datadog_monitor.mysql_thread_too_high.id}" +output "mysql_connection_id" { + description = "id for monitor mysql_connection" + value = "${datadog_monitor.mysql_connection.id}" +} + +output "mysql_aborted_id" { + description = "id for monitor mysql_aborted" + value = "${datadog_monitor.mysql_aborted.id}" +} + +output "mysql_slow_id" { + description = "id for monitor mysql_slow" + value = "${datadog_monitor.mysql_slow.id}" +} + +output "mysql_pool_efficiency_id" { + description = "id for monitor mysql_pool_efficiency" + value = "${datadog_monitor.mysql_pool_efficiency.id}" +} + +output "mysql_pool_utilization_id" { + description = "id for monitor mysql_pool_utilization" + value = "${datadog_monitor.mysql_pool_utilization.id}" +} + +output "mysql_threads_anomaly_id" { + description = "id for monitor mysql_threads_anomaly" + value = "${datadog_monitor.mysql_threads_anomaly.id}" +} + +output "mysql_queries_anomaly_id" { + description = "id for monitor mysql_queries_anomaly" + value = "${datadog_monitor.mysql_queries_anomaly.id}" } From 761b6b4620ace3d35d6e0838a8d0206f31a75c30 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 17:01:27 +0200 Subject: [PATCH 27/33] MON-142 better name for connection limit --- database/mysql/monitors-mysql.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index 03404ca..5e8b11a 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -28,7 +28,7 @@ resource "datadog_monitor" "mysql_availability" { } resource "datadog_monitor" "mysql_connection" { - name = "[${var.environment}] Mysql Connections {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" + name = "[${var.environment}] Mysql Connections limit {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}" message = "${coalesce(var.mysql_connection_message, var.message)}" type = "metric alert" From 84beab806cf72e06300d5d959eea6dccd14a2978 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 17:05:09 +0200 Subject: [PATCH 28/33] MON-142 fix threads connected metric --- database/mysql/monitors-mysql.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index 5e8b11a..ebc523e 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -66,7 +66,7 @@ resource "datadog_monitor" "mysql_aborted" { query = < ${var.mysql_aborted_threshold_critical} EOF From 728280e348318641a5bb179a2233b62acc097c36 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 17:12:31 +0200 Subject: [PATCH 29/33] MON-142 set explicitely threshold_windows --- database/mysql/monitors-mysql.tf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index ebc523e..db66b27 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -211,6 +211,11 @@ resource "datadog_monitor" "mysql_threads_anomaly" { critical_recovery = 0 } + threshold_windows = { + recovery_window = "${var.mysql_threads_alert_window}" + trigger_window = "${var.mysql_threads_alert_window}" + } + notify_no_data = false renotify_interval = 0 require_full_window = true @@ -250,6 +255,11 @@ resource "datadog_monitor" "mysql_queries_anomaly" { critical_recovery = 0 } + threshold_windows = { + recovery_window = "${var.mysql_queries_alert_window}" + trigger_window = "${var.mysql_queries_alert_window}" + } + notify_no_data = false renotify_interval = 0 require_full_window = true From 227dcd130916f4900916b229465780f9792d1cc8 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 17:13:19 +0200 Subject: [PATCH 30/33] MON-142 auto update --- database/mysql/README.md | 2 +- database/mysql/monitors-mysql.tf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database/mysql/README.md b/database/mysql/README.md index 73f60e1..7af8c11 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -17,7 +17,7 @@ module "datadog-monitors-database-mysql" { Creates DataDog monitors with the following checks: - Mysql server does not respond -- Mysql Connections +- Mysql Connections limit - Mysql Aborted connects - Mysql Slow queries - Mysql Innodb buffer pool efficiency diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index db66b27..d34ed8b 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -213,7 +213,7 @@ resource "datadog_monitor" "mysql_threads_anomaly" { threshold_windows = { recovery_window = "${var.mysql_threads_alert_window}" - trigger_window = "${var.mysql_threads_alert_window}" + trigger_window = "${var.mysql_threads_alert_window}" } notify_no_data = false @@ -257,7 +257,7 @@ resource "datadog_monitor" "mysql_queries_anomaly" { threshold_windows = { recovery_window = "${var.mysql_queries_alert_window}" - trigger_window = "${var.mysql_queries_alert_window}" + trigger_window = "${var.mysql_queries_alert_window}" } notify_no_data = false From 1bd8ab087129ed5728d94fdb6990ccdae51a6603 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 17:29:34 +0200 Subject: [PATCH 31/33] MON-142 make the queries anomaly monitor more tolerant --- database/mysql/README.md | 2 +- database/mysql/inputs.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database/mysql/README.md b/database/mysql/README.md index 7af8c11..d70910d 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -69,7 +69,7 @@ Creates DataDog monitors with the following checks: | mysql_queries_alert_window | Alert window. | string | `last_15m` | no | | mysql_queries_count_default_zero | Count default zero. | string | `true` | no | | mysql_queries_detection_algorithm | Anomaly Detection Algorithm used | string | `agile` | no | -| mysql_queries_deviations | Deviations to detect the anomaly | string | `2` | no | +| mysql_queries_deviations | Deviations to detect the anomaly | string | `5` | no | | mysql_queries_direction | Direction of the anomaly. It can be both, below or above. | string | `both` | no | | mysql_queries_extra_tags | Extra tags for MySQL queries monitor | list | `` | no | | mysql_queries_interval | Interval. | string | `60` | no | diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index 35944ee..8c467df 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -376,7 +376,7 @@ variable "mysql_queries_detection_algorithm" { variable "mysql_queries_deviations" { description = "Deviations to detect the anomaly" type = "string" - default = 2 + default = 5 } variable "mysql_queries_direction" { From d6af7e7c38352426e6def597ef340d5fa176d325 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 27 Aug 2018 18:09:54 +0200 Subject: [PATCH 32/33] MON-142 revert threshold_windows --- database/mysql/monitors-mysql.tf | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index d34ed8b..ebc523e 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -211,11 +211,6 @@ resource "datadog_monitor" "mysql_threads_anomaly" { critical_recovery = 0 } - threshold_windows = { - recovery_window = "${var.mysql_threads_alert_window}" - trigger_window = "${var.mysql_threads_alert_window}" - } - notify_no_data = false renotify_interval = 0 require_full_window = true @@ -255,11 +250,6 @@ resource "datadog_monitor" "mysql_queries_anomaly" { critical_recovery = 0 } - threshold_windows = { - recovery_window = "${var.mysql_queries_alert_window}" - trigger_window = "${var.mysql_queries_alert_window}" - } - notify_no_data = false renotify_interval = 0 require_full_window = true From 1a8cfac34f85f931b44fb3cc7d7ed89098d5881e Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Tue, 28 Aug 2018 09:26:32 +0200 Subject: [PATCH 33/33] MON-142 fix typo --- database/mysql/README.md | 2 +- database/mysql/inputs.tf | 2 +- database/mysql/monitors-mysql.tf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/database/mysql/README.md b/database/mysql/README.md index d70910d..9e5d507 100644 --- a/database/mysql/README.md +++ b/database/mysql/README.md @@ -44,7 +44,7 @@ Creates DataDog monitors with the following checks: | mysql_availability_extra_tags | Extra tags for Mysql availability monitor | list | `` | no | | mysql_availability_message | Custom message for Mysql availability monitor | string | `` | no | | mysql_availability_silenced | Groups to mute for Mysql availability monitor | map | `` | no | -| mysql_availability_threshold_critical | Nginx status monitor (critical threshold) | string | `1.1754943508222875e-38` | no | +| mysql_availability_threshold_critical | Mysql availability monitor (critical threshold) | string | `1.1754943508222875e-38` | no | | mysql_connection_extra_tags | Extra tags for MySQL connection monitor | list | `` | no | | mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no | | mysql_connection_silenced | Groups to mute MySQL connection monitor | map | `` | no | diff --git a/database/mysql/inputs.tf b/database/mysql/inputs.tf index 8c467df..f20d62d 100644 --- a/database/mysql/inputs.tf +++ b/database/mysql/inputs.tf @@ -52,7 +52,7 @@ variable "mysql_availability_message" { } variable "mysql_availability_threshold_critical" { - description = "Nginx status monitor (critical threshold)" + description = "Mysql availability monitor (critical threshold)" type = "string" default = 1.1754943508222875e-38 } diff --git a/database/mysql/monitors-mysql.tf b/database/mysql/monitors-mysql.tf index ebc523e..2a13d9c 100644 --- a/database/mysql/monitors-mysql.tf +++ b/database/mysql/monitors-mysql.tf @@ -24,7 +24,7 @@ resource "datadog_monitor" "mysql_availability" { silenced = "${var.mysql_availability_silenced}" - tags = ["env:${var.environment}", "type:middleware", "provider:php-fpm", "resource:php-fpm", "team:claranet", "created-by:terraform", "${var.mysql_availability_extra_tags}"] + tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"] } resource "datadog_monitor" "mysql_connection" {