From 220dfe019dec2656687f8eddb25a18146159cb06 Mon Sep 17 00:00:00 2001 From: Alexandre Gaillet Date: Tue, 7 Nov 2017 11:58:54 +0100 Subject: [PATCH] MON-75 Add some descriptions and add EOF on queries --- cloud/azure/sql-database/README.md | 29 +++++---- cloud/azure/sql-database/inputs.tf | 65 +++++++++++++------ .../monitors-sql-database-basics.tf | 36 ++++++---- 3 files changed, 84 insertions(+), 46 deletions(-) diff --git a/cloud/azure/sql-database/README.md b/cloud/azure/sql-database/README.md index 5fb0387..f135036 100644 --- a/cloud/azure/sql-database/README.md +++ b/cloud/azure/sql-database/README.md @@ -27,18 +27,19 @@ Creates a DataDog monitors with the following checks : Inputs ------ -| Name | Type | Default | Required | -|------|:----:|:-------:|:--------:| -| client_name | Client name | string | - | yes | +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| cpu_threshold_critical | CPU usage in percent (critical threshold) | string | `90` | no | +| cpu_threshold_warning | CPU usage in percent (warning threshold) | string | `` | no | +| deadlock_threshold_critical | Amount of Deadlocks (critical threshold) | string | `1` | no | | delay | Delay in seconds for the metric evaluation | string | `600` | no | -| environment | Architecture environment | string | - | yes | -| message | Message sent when a monitor is triggered | string | - | yes | -| use_filter_tags | Filter the data with service tags if true | string | `false` | no | -| dd_azure_sqldb | string | `disabled` | yes | -| cpu_threshold_warning | string | `85` | no | -| cpu_threshold_critical | string | `90` | no | -| diskspace_threshold_warning | string | `80` | no | -| diskspace_threshold_critical | string | `90` | no | -| dtu_threshold_warning | string | `85` | no | -| dtu_threshold_critical | string | `90` | no | -| deadlock_threshold_critical | string | `1` | no | +| diskspace_threshold_critical | Disk space used in percent (critical threshold) | string | `90` | no | +| diskspace_threshold_warning | Disk space used in percent (warning threshold) | string | `80` | no | +| dtu_threshold_critical | Amount of DTU used (critical threshold) | string | `90` | no | +| dtu_threshold_warning | Amount of DTU used (warning threshold) | string | `85` | no | +| environment | Architecture Environment | string | - | yes | +| message | Message sent when an alert is triggered | string | - | yes | +| provider | Cloud provider which the monitor and its based metric depend on | string | `azure` | no | +| service | Service monitored by this set of monitors | string | `sql-database` | no | +| subscription_id | Azure account id used as filter for monitors | string | - | yes | +| use_filter_tags | Filter the data with service tags if true | string | `true` | no | diff --git a/cloud/azure/sql-database/inputs.tf b/cloud/azure/sql-database/inputs.tf index 77599b9..d3abe46 100644 --- a/cloud/azure/sql-database/inputs.tf +++ b/cloud/azure/sql-database/inputs.tf @@ -1,49 +1,74 @@ +# Global Terraform +variable "environment" { + description = "Architecture Environment" + type = "string" +} + variable "subscription_id" { - default = "" + description = "Azure account id used as filter for monitors" + type = "string" +} + +variable "provider" { + description = "Cloud provider which the monitor and its based metric depend on" + type = "string" + default = "azure" +} + +variable "service" { + description = "Service monitored by this set of monitors" + type = "string" + default = "sql-database" +} + +# Global DataDog +variable "delay" { + description = "Delay in seconds for the metric evaluation" + default = 600 } variable "message" { - description = "Message sent when a SQL DB monitor is triggered" + description = "Message sent when an alert is triggered" } -variable "environment" {} - variable "use_filter_tags" { - default = "false" + description = "Filter the data with service tags if true" + default = "true" } +# Azure SQL Database specific + variable "cpu_threshold_warning" { - default = "" + description = "CPU usage in percent (warning threshold)" + default = "" } variable "cpu_threshold_critical" { - default = "90" + description = "CPU usage in percent (critical threshold)" + default = "90" } variable "diskspace_threshold_warning" { - default = "80" + description = "Disk space used in percent (warning threshold)" + default = "80" } variable "diskspace_threshold_critical" { - default = "90" + description = "Disk space used in percent (critical threshold)" + default = "90" } variable "dtu_threshold_warning" { - default = "85" + description = "Amount of DTU used (warning threshold)" + default = "85" } variable "dtu_threshold_critical" { - default = "90" + description = "Amount of DTU used (critical threshold)" + default = "90" } variable "deadlock_threshold_critical" { - default = "1" -} - -variable "delay" { - default = "600" -} - -variable "dd_azure_sqldb" { - default = "disabled" + description = "Amount of Deadlocks (critical threshold)" + default = "1" } diff --git a/cloud/azure/sql-database/monitors-sql-database-basics.tf b/cloud/azure/sql-database/monitors-sql-database-basics.tf index 413e4020..5448b8a 100644 --- a/cloud/azure/sql-database/monitors-sql-database-basics.tf +++ b/cloud/azure/sql-database/monitors-sql-database-basics.tf @@ -10,10 +10,13 @@ resource "datadog_monitor" "sql-database_cpu_90_15min" { name = "[${var.environment}] SQL Database CPU high > 90% for 15 min on {{name}}" message = "${message}" - count = "${var.dd_azure_sqldb == "enabled" ? 1 : 0 }" + query = < ${var.cpu_threshold_critical} + EOF - query = "avg(last_15m):avg:azure.sql_servers_databases.cpu_percent{${data.template_file.filter.rendered}} by {name,resource_group} > ${var.cpu_threshold_critical}" - type = "query alert" + type = "query alert" thresholds { critical = "${var.cpu_threshold_critical}" @@ -35,10 +38,13 @@ resource "datadog_monitor" "sql-database_free_space_low" { name = "[${var.environment}] SQL Database free space < 10 % on {{name}}" message = "${message}" - type = "query alert" - query = "avg(last_15m):avg:azure.sql_servers_databases.storage_percent{${data.template_file.filter.rendered}} by {name,resource_group} > 90" + type = "query alert" - count = "${var.dd_azure_sqldb == "enabled" ? 1 : 0 }" + query = < ${var.diskspace_threshold_critical} + EOF thresholds { warning = "${var.diskspace_threshold_warning}" @@ -61,10 +67,13 @@ resource "datadog_monitor" "sql-database_dtu_consumption_high" { name = "[${var.environment}] DTU Consumption on {{name}} > 90" message = "${message}" - type = "query alert" - query = "avg(last_15m):azure.sql_servers_databases.dtu_consumption_percent{${data.template_file.filter.rendered}} by {name,resource_group} > 90" + type = "query alert" - count = "${var.dd_azure_sqldb == "enabled" ? 1 : 0 }" + query = < ${var.dtu_threshold_critical} + EOF thresholds { warning = "${var.dtu_threshold_warning}" @@ -87,10 +96,13 @@ resource "datadog_monitor" "sql-database_deadlocks_count" { name = "[${var.environment}] SQL Deadlocks too high on {{name}}" message = "${message}" - type = "query alert" - query = "sum(last_5m):avg:azure.sql_servers_databases.deadlock{${data.template_file.filter.rendered}} by {name,resource_group}.as_count() > ${var.deadlock_threshold_critical}" + type = "query alert" - count = "${var.dd_azure_sqldb == "enabled" ? 1 : 0 }" + query = < ${var.deadlock_threshold_critical} + EOF thresholds { critical = "${var.deadlock_threshold_critical}"