Merge branch 'MON-377-azure-sql-server-status' into 'master'

MON-377 Azure SQL Server status

Closes MON-377

See merge request claranet/cloudnative/projects/datadog/terraform/monitors!10
This commit is contained in:
Quentin Manfroi 2019-01-03 10:18:16 +01:00
commit 82c537e6bd
4 changed files with 77 additions and 0 deletions

View File

@ -19,6 +19,7 @@ Creates DataDog monitors with the following checks:
- SQL Database CPU too high
- SQL Database Deadlocks too high
- SQL Database DTU Consumption too high
- SQL Database is down
- SQL Database low free space
## Inputs
@ -62,6 +63,12 @@ Creates DataDog monitors with the following checks:
| filter_tags_use_defaults | Use default filter tags convention | string | `true` | no |
| message | Message sent when an alert is triggered | string | - | yes |
| new_host_delay | Delay in seconds before monitor new resource | string | `300` | no |
| status_enabled | Flag to enable Redis status monitor | string | `true` | no |
| status_extra_tags | Extra tags for Redis status monitor | list | `[]` | no |
| status_message | Custom message for Redis status monitor | string | `` | no |
| status_silenced | Groups to mute for Redis status monitor | map | `{}` | no |
| status_time_aggregator | Monitor aggregator for Redis status [available values: min, max or avg] | string | `max` | no |
| status_timeframe | Monitor timeframe for Redis status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
## Outputs
@ -71,6 +78,7 @@ Creates DataDog monitors with the following checks:
| sql-database_deadlocks_count_id | id for monitor sql-database_deadlocks_count |
| sql-database_dtu_consumption_high_id | id for monitor sql-database_dtu_consumption_high |
| sql-database_free_space_low_id | id for monitor sql-database_free_space_low |
| status_id | id for monitor status |
## Related documentation

View File

@ -35,6 +35,42 @@ variable "filter_tags_custom_excluded" {
}
# Azure SQL Database specific variables
variable "status_silenced" {
description = "Groups to mute for Redis status monitor"
type = "map"
default = {}
}
variable "status_enabled" {
description = "Flag to enable Redis status monitor"
type = "string"
default = "true"
}
variable "status_extra_tags" {
description = "Extra tags for Redis status monitor"
type = "list"
default = []
}
variable "status_message" {
description = "Custom message for Redis status monitor"
type = "string"
default = ""
}
variable "status_time_aggregator" {
description = "Monitor aggregator for Redis status [available values: min, max or avg]"
type = "string"
default = "max"
}
variable "status_timeframe" {
description = "Monitor timeframe for Redis status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = "string"
default = "last_5m"
}
variable "cpu_silenced" {
description = "Groups to mute for SQL CPU monitor"
type = "map"

View File

@ -1,3 +1,31 @@
resource "datadog_monitor" "status" {
count = "${var.status_enabled ? 1 : 0}"
name = "[${var.environment}] SQL Database is down"
message = "${coalesce(var.status_message, var.message)}"
query = <<EOF
${var.status_time_aggregator}(${var.status_timeframe}): (
avg:azure.sql_servers_databases.status${module.filter-tags.query_alert} by {resource_group,region,server_name,name}
) != 1
EOF
type = "metric alert"
silenced = "${var.status_silenced}"
notify_no_data = true
evaluation_delay = "${var.evaluation_delay}"
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
new_host_delay = "${var.new_host_delay}"
tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:sql-database", "team:claranet", "created-by:terraform", "${var.status_extra_tags}"]
}
resource "datadog_monitor" "sql-database_cpu_90_15min" {
count = "${var.cpu_enabled ? 1 : 0}"
name = "[${var.environment}] SQL Database CPU too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"

View File

@ -1,3 +1,8 @@
output "status_id" {
description = "id for monitor status"
value = "${datadog_monitor.status.*.id}"
}
output "sql-database_cpu_90_15min_id" {
description = "id for monitor sql-database_cpu_90_15min"
value = "${datadog_monitor.sql-database_cpu_90_15min.*.id}"