diff --git a/cloud/azure/sql-database/README.md b/cloud/azure/sql-database/README.md index f135036..7d815e3 100644 --- a/cloud/azure/sql-database/README.md +++ b/cloud/azure/sql-database/README.md @@ -1,5 +1,5 @@ Azure SQL Database DataDog monitors -============================ +=================================== How to use this module ---------------------- @@ -8,10 +8,8 @@ How to use this module module "datadog-monitors-azure-storage" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/sql-database?ref={revision}" - message = "${module.datadog-message-alerting.alerting-message}" - + message = "${module.datadog-message-alerting.alerting-message}" environment = "${var.environment}" - client_name = "${var.client_name}" } ``` @@ -38,8 +36,14 @@ Inputs | 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 | +| 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 | -| 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 | + +Related documentation +--------------------- + +DataDog documentation: [https://docs.datadoghq.com/integrations/azure_sql_database/](https://docs.datadoghq.com/integrations/azure_sql_database/) + +Azure SQL Database metrics documentation: [https://docs.microsoft.com/en-us/azure/sql-database/saas-dbpertenant-log-analytics](https://docs.microsoft.com/en-us/azure/sql-database/saas-dbpertenant-log-analytics) + diff --git a/cloud/azure/sql-database/inputs.tf b/cloud/azure/sql-database/inputs.tf index d3abe46..9ddab06 100644 --- a/cloud/azure/sql-database/inputs.tf +++ b/cloud/azure/sql-database/inputs.tf @@ -4,23 +4,6 @@ variable "environment" { type = "string" } -variable "subscription_id" { - 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" @@ -31,11 +14,16 @@ variable "message" { description = "Message sent when an alert is triggered" } -variable "use_filter_tags" { - description = "Filter the data with service tags if true" +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 = "*" +} + # Azure SQL Database specific variable "cpu_threshold_warning" { diff --git a/cloud/azure/sql-database/monitors-sql-database-basics.tf b/cloud/azure/sql-database/monitors-sql-database-basics.tf index 5448b8a..1e75813 100644 --- a/cloud/azure/sql-database/monitors-sql-database-basics.tf +++ b/cloud/azure/sql-database/monitors-sql-database-basics.tf @@ -2,13 +2,13 @@ data "template_file" "filter" { template = "$${filter}" vars { - filter = "${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_sqldb:enabled,env:%s",var.environment) : "*"}" + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_azure_sqldatabase:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" } } resource "datadog_monitor" "sql-database_cpu_90_15min" { - name = "[${var.environment}] SQL Database CPU high > 90% for 15 min on {{name}}" - message = "${message}" + name = "[${var.environment}] SQL Database CPU high > ${var.cpu_threshold_critical}% on {{name}}" + message = "${var.message}" query = < ${var.cpu_threshold_critical} EOF - type = "query alert" + type = "metric alert" thresholds { critical = "${var.cpu_threshold_critical}" @@ -32,13 +32,15 @@ resource "datadog_monitor" "sql-database_cpu_90_15min" { require_full_window = true new_host_delay = "${var.delay}" no_data_timeframe = 20 + + tags = ["env:${var.environment}", "resource:sqldatabase", "team:azure", "provider:azure"] } resource "datadog_monitor" "sql-database_free_space_low" { - name = "[${var.environment}] SQL Database free space < 10 % on {{name}}" - message = "${message}" + name = "[${var.environment}] SQL Database free space < ${var.diskspace_threshold_critical}% on {{name}}" + message = "${var.message}" - type = "query alert" + type = "metric alert" query = <