MON-75 Normalize monitors
This commit is contained in:
parent
220dfe019d
commit
28e2e87a93
@ -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)
|
||||
|
||||
|
||||
@ -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" {
|
||||
|
||||
@ -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 = <<EOF
|
||||
avg(last_15m): (
|
||||
@ -16,7 +16,7 @@ resource "datadog_monitor" "sql-database_cpu_90_15min" {
|
||||
) > ${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 = <<EOF
|
||||
avg(last_15m): (
|
||||
@ -61,13 +63,15 @@ resource "datadog_monitor" "sql-database_free_space_low" {
|
||||
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_dtu_consumption_high" {
|
||||
name = "[${var.environment}] DTU Consumption on {{name}} > 90"
|
||||
message = "${message}"
|
||||
name = "[${var.environment}] SQL Database DTU Consumption on {{name}} > ${var.dtu_threshold_critical}"
|
||||
message = "${var.message}"
|
||||
|
||||
type = "query alert"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
avg(last_15m): (
|
||||
@ -90,13 +94,15 @@ resource "datadog_monitor" "sql-database_dtu_consumption_high" {
|
||||
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_deadlocks_count" {
|
||||
name = "[${var.environment}] SQL Deadlocks too high on {{name}}"
|
||||
message = "${message}"
|
||||
name = "[${var.environment}] SQL Database Deadlocks too high on {{name}}"
|
||||
message = "${var.message}"
|
||||
|
||||
type = "query alert"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
sum(last_5m): (
|
||||
@ -118,4 +124,6 @@ resource "datadog_monitor" "sql-database_deadlocks_count" {
|
||||
require_full_window = true
|
||||
new_host_delay = "${var.delay}"
|
||||
no_data_timeframe = 20
|
||||
|
||||
tags = ["env:${var.environment}", "resource:sqldatabase", "team:azure", "provider:azure"]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user