MON-402 Fix Active connection monitor
This commit is contained in:
parent
7a7c8ae9de
commit
270812f7c5
@ -8,6 +8,8 @@ module "datadog-monitors-cloud-azure-mysql" {
|
|||||||
|
|
||||||
environment = "${var.environment}"
|
environment = "${var.environment}"
|
||||||
message = "${module.datadog-message-alerting.alerting-message}"
|
message = "${module.datadog-message-alerting.alerting-message}"
|
||||||
|
|
||||||
|
total_connection_limit = "${var.total_connection_limit}"
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -17,7 +19,7 @@ module "datadog-monitors-cloud-azure-mysql" {
|
|||||||
Creates DataDog monitors with the following checks:
|
Creates DataDog monitors with the following checks:
|
||||||
|
|
||||||
- Mysql Server CPU usage
|
- Mysql Server CPU usage
|
||||||
- Mysql Server has no connection
|
- Mysql Server has total connection
|
||||||
- Mysql Server IO consumption
|
- Mysql Server IO consumption
|
||||||
- Mysql Server memory usage
|
- Mysql Server memory usage
|
||||||
- Mysql Server storage
|
- Mysql Server storage
|
||||||
@ -26,50 +28,51 @@ Creates DataDog monitors with the following checks:
|
|||||||
|
|
||||||
| Name | Description | Type | Default | Required |
|
| Name | Description | Type | Default | Required |
|
||||||
|------|-------------|:----:|:-----:|:-----:|
|
|------|-------------|:----:|:-----:|:-----:|
|
||||||
| cpu\_usage\_enabled | Flag to enable Mysql status monitor | string | `"true"` | no |
|
| cpu_usage_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||||
| cpu\_usage\_extra\_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
| cpu_usage_extra_tags | Extra tags for Mysql status monitor | list | `<list>` | no |
|
||||||
| cpu\_usage\_message | Custom message for Mysql CPU monitor | string | `""` | no |
|
| cpu_usage_message | Custom message for Mysql CPU monitor | string | `` | no |
|
||||||
| cpu\_usage\_silenced | Groups to mute for Mysql CPU monitor | map | `{}` | no |
|
| cpu_usage_silenced | Groups to mute for Mysql CPU monitor | map | `<map>` | no |
|
||||||
| cpu\_usage\_threshold\_critical | Mysql CPU usage in percent (critical threshold) | string | `"90"` | no |
|
| cpu_usage_threshold_critical | Mysql CPU usage in percent (critical threshold) | string | `90` | no |
|
||||||
| cpu\_usage\_threshold\_warning | Mysql CPU usage in percent (warning threshold) | string | `"80"` | no |
|
| cpu_usage_threshold_warning | Mysql CPU usage in percent (warning threshold) | string | `80` | no |
|
||||||
| cpu\_usage\_time\_aggregator | Monitor aggregator for Mysql CPU [available values: min, max or avg] | string | `"min"` | no |
|
| cpu_usage_time_aggregator | Monitor aggregator for Mysql CPU [available values: min, max or avg] | string | `min` | no |
|
||||||
| cpu\_usage\_timeframe | Monitor timeframe for Mysql CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no |
|
| cpu_usage_timeframe | Monitor timeframe for Mysql CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
|
||||||
| environment | Architecture environment | string | n/a | yes |
|
| environment | Architecture environment | string | - | yes |
|
||||||
| evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no |
|
| evaluation_delay | Delay in seconds for the metric evaluation | string | `900` | no |
|
||||||
| filter\_tags\_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `"*"` | 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 |
|
| filter_tags_use_defaults | Use default filter tags convention | string | `true` | no |
|
||||||
| free\_storage\_enabled | Flag to enable Mysql status monitor | string | `"true"` | no |
|
| free_storage_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||||
| free\_storage\_extra\_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
| free_storage_extra_tags | Extra tags for Mysql status monitor | list | `<list>` | no |
|
||||||
| free\_storage\_message | Custom message for Mysql Free Storage monitor | string | `""` | no |
|
| free_storage_message | Custom message for Mysql Free Storage monitor | string | `` | no |
|
||||||
| free\_storage\_silenced | Groups to mute for Mysql Free Storage monitor | map | `{}` | no |
|
| free_storage_silenced | Groups to mute for Mysql Free Storage monitor | map | `<map>` | no |
|
||||||
| free\_storage\_threshold\_critical | Mysql Free Storage remaining in percent (critical threshold) | string | `"10"` | no |
|
| free_storage_threshold_critical | Mysql Free Storage remaining in percent (critical threshold) | string | `10` | no |
|
||||||
| free\_storage\_threshold\_warning | Mysql Free Storage remaining in percent (warning threshold) | string | `"20"` | no |
|
| free_storage_threshold_warning | Mysql Free Storage remaining in percent (warning threshold) | string | `20` | no |
|
||||||
| free\_storage\_time\_aggregator | Monitor aggregator for Mysql Free Storage [available values: min, max or avg] | string | `"min"` | no |
|
| free_storage_time_aggregator | Monitor aggregator for Mysql Free Storage [available values: min, max or avg] | string | `min` | no |
|
||||||
| free\_storage\_timeframe | Monitor timeframe for Mysql Free Storage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no |
|
| free_storage_timeframe | Monitor timeframe for Mysql Free Storage [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
|
||||||
| io\_consumption\_enabled | Flag to enable Mysql status monitor | string | `"true"` | no |
|
| io_consumption_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||||
| io\_consumption\_extra\_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
| io_consumption_extra_tags | Extra tags for Mysql status monitor | list | `<list>` | no |
|
||||||
| io\_consumption\_message | Custom message for Mysql IO consumption monitor | string | `""` | no |
|
| io_consumption_message | Custom message for Mysql IO consumption monitor | string | `` | no |
|
||||||
| io\_consumption\_silenced | Groups to mute for Mysql IO consumption monitor | map | `{}` | no |
|
| io_consumption_silenced | Groups to mute for Mysql IO consumption monitor | map | `<map>` | no |
|
||||||
| io\_consumption\_threshold\_critical | Mysql IO consumption in percent (critical threshold) | string | `"90"` | no |
|
| io_consumption_threshold_critical | Mysql IO consumption in percent (critical threshold) | string | `90` | no |
|
||||||
| io\_consumption\_threshold\_warning | Mysql IO consumption in percent (warning threshold) | string | `"80"` | no |
|
| io_consumption_threshold_warning | Mysql IO consumption in percent (warning threshold) | string | `80` | no |
|
||||||
| io\_consumption\_time\_aggregator | Monitor aggregator for Mysql IO consumption [available values: min, max or avg] | string | `"min"` | no |
|
| io_consumption_time_aggregator | Monitor aggregator for Mysql IO consumption [available values: min, max or avg] | string | `min` | no |
|
||||||
| io\_consumption\_timeframe | Monitor timeframe for Mysql IO consumption [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no |
|
| io_consumption_timeframe | Monitor timeframe for Mysql IO consumption [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
|
||||||
| memory\_usage\_enabled | Flag to enable Mysql status monitor | string | `"true"` | no |
|
| memory_usage_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||||
| memory\_usage\_extra\_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
| memory_usage_extra_tags | Extra tags for Mysql status monitor | list | `<list>` | no |
|
||||||
| memory\_usage\_message | Custom message for Mysql memory monitor | string | `""` | no |
|
| memory_usage_message | Custom message for Mysql memory monitor | string | `` | no |
|
||||||
| memory\_usage\_silenced | Groups to mute for Mysql memory monitor | map | `{}` | no |
|
| memory_usage_silenced | Groups to mute for Mysql memory monitor | map | `<map>` | no |
|
||||||
| memory\_usage\_threshold\_critical | Mysql memory usage in percent (critical threshold) | string | `"90"` | no |
|
| memory_usage_threshold_critical | Mysql memory usage in percent (critical threshold) | string | `90` | no |
|
||||||
| memory\_usage\_threshold\_warning | Mysql memory usage in percent (warning threshold) | string | `"80"` | no |
|
| memory_usage_threshold_warning | Mysql memory usage in percent (warning threshold) | string | `80` | no |
|
||||||
| memory\_usage\_time\_aggregator | Monitor aggregator for Mysql memory [available values: min, max or avg] | string | `"min"` | no |
|
| memory_usage_time_aggregator | Monitor aggregator for Mysql memory [available values: min, max or avg] | string | `min` | no |
|
||||||
| memory\_usage\_timeframe | Monitor timeframe for Mysql memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_15m"` | no |
|
| memory_usage_timeframe | Monitor timeframe for Mysql memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
|
||||||
| message | Message sent when an alert is triggered | string | n/a | yes |
|
| message | Message sent when an alert is triggered | string | - | yes |
|
||||||
| new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no |
|
| new_host_delay | Delay in seconds before monitor new resource | string | `300` | no |
|
||||||
| no\_connection\_enabled | Flag to enable Mysql status monitor | string | `"true"` | no |
|
| total_connection_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||||
| no\_connection\_extra\_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
| total_connection_extra_tags | Extra tags for Mysql status monitor | list | `<list>` | no |
|
||||||
| no\_connection\_message | Custom message for Mysql no connection monitor | string | `""` | no |
|
| total_connection_limit | Limit for Mysql total connection [See details : https://docs.microsoft.com/en-us/azure/mysql/concepts-limits] | string | `` | no |
|
||||||
| no\_connection\_silenced | Groups to mute for Mysql no connection monitor | map | `{}` | no |
|
| total_connection_message | Custom message for Mysql total connection monitor | string | `` | no |
|
||||||
| no\_connection\_time\_aggregator | Monitor aggregator for Mysql no connection [available values: min, max or avg] | string | `"min"` | no |
|
| total_connection_silenced | Groups to mute for Mysql total connection monitor | map | `<map>` | no |
|
||||||
| no\_connection\_timeframe | Monitor timeframe for Mysql no connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
|
| total_connection_time_aggregator | Monitor aggregator for Mysql total connection [available values: min, max or avg] | string | `min` | no |
|
||||||
|
| total_connection_timeframe | Monitor timeframe for Mysql total connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ Creates DataDog monitors with the following checks:
|
|||||||
| mysql\_free\_storage\_id | id for monitor mysql_free_storage |
|
| mysql\_free\_storage\_id | id for monitor mysql_free_storage |
|
||||||
| mysql\_io\_consumption\_id | id for monitor mysql_io_consumption |
|
| mysql\_io\_consumption\_id | id for monitor mysql_io_consumption |
|
||||||
| mysql\_memory\_usage\_id | id for monitor mysql_memory_usage |
|
| mysql\_memory\_usage\_id | id for monitor mysql_memory_usage |
|
||||||
| mysql\_no\_connection\_id | id for monitor mysql_no_connection |
|
| mysql\_total\_connection\_id | id for monitor mysql_total_connection |
|
||||||
|
|
||||||
## Related documentation
|
## Related documentation
|
||||||
|
|
||||||
|
|||||||
@ -76,42 +76,48 @@ variable "cpu_usage_threshold_critical" {
|
|||||||
default = "90"
|
default = "90"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "no_connection_silenced" {
|
variable "total_connection_silenced" {
|
||||||
description = "Groups to mute for Mysql no connection monitor"
|
description = "Groups to mute for Mysql total connection monitor"
|
||||||
type = "map"
|
type = "map"
|
||||||
default = {}
|
default = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "no_connection_enabled" {
|
variable "total_connection_enabled" {
|
||||||
description = "Flag to enable Mysql status monitor"
|
description = "Flag to enable Mysql status monitor"
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "true"
|
default = "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "no_connection_extra_tags" {
|
variable "total_connection_extra_tags" {
|
||||||
description = "Extra tags for Mysql status monitor"
|
description = "Extra tags for Mysql status monitor"
|
||||||
type = "list"
|
type = "list"
|
||||||
default = []
|
default = []
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "no_connection_message" {
|
variable "total_connection_message" {
|
||||||
description = "Custom message for Mysql no connection monitor"
|
description = "Custom message for Mysql total connection monitor"
|
||||||
type = "string"
|
type = "string"
|
||||||
default = ""
|
default = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "no_connection_time_aggregator" {
|
variable "total_connection_time_aggregator" {
|
||||||
description = "Monitor aggregator for Mysql no connection [available values: min, max or avg]"
|
description = "Monitor aggregator for Mysql total connection [available values: min, max or avg]"
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "min"
|
default = "min"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "no_connection_timeframe" {
|
variable "total_connection_timeframe" {
|
||||||
description = "Monitor timeframe for Mysql no connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
description = "Monitor timeframe for Mysql total connection [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "last_5m"
|
default = "last_5m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "total_connection_limit" {
|
||||||
|
description = "Limit for Mysql total connection [See details : https://docs.microsoft.com/en-us/azure/mysql/concepts-limits]"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
variable "free_storage_silenced" {
|
variable "free_storage_silenced" {
|
||||||
description = "Groups to mute for Mysql Free Storage monitor"
|
description = "Groups to mute for Mysql Free Storage monitor"
|
||||||
type = "map"
|
type = "map"
|
||||||
|
|||||||
@ -31,20 +31,20 @@ resource "datadog_monitor" "mysql_cpu_usage" {
|
|||||||
tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"]
|
tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "datadog_monitor" "mysql_no_connection" {
|
resource "datadog_monitor" "mysql_total_connection" {
|
||||||
count = "${var.no_connection_enabled ? 1 : 0}"
|
count = "${var.total_connection_enabled ? 1 : 0}"
|
||||||
name = "[${var.environment}] Mysql Server has no connection"
|
name = "[${var.environment}] Mysql Server total connection reach 80 percent of the total limit"
|
||||||
message = "${coalesce(var.no_connection_message, var.message)}"
|
message = "${coalesce(var.total_connection_message, var.message)}"
|
||||||
|
|
||||||
query = <<EOF
|
query = <<EOF
|
||||||
${var.no_connection_time_aggregator}(${var.no_connection_timeframe}): (
|
${var.total_connection_time_aggregator}(${var.total_connection_timeframe}): (
|
||||||
avg:azure.dbformysql_servers.active_connections${module.filter-tags.query_alert} by {resource_group,region,name}
|
avg:azure.dbformysql_servers.active_connections${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||||
) < 1
|
) > (${var.total_connection_limit} * 0.8)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
type = "metric alert"
|
type = "metric alert"
|
||||||
|
|
||||||
silenced = "${var.no_connection_silenced}"
|
silenced = "${var.total_connection_silenced}"
|
||||||
|
|
||||||
notify_no_data = true
|
notify_no_data = true
|
||||||
evaluation_delay = "${var.evaluation_delay}"
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
@ -56,7 +56,7 @@ resource "datadog_monitor" "mysql_no_connection" {
|
|||||||
require_full_window = false
|
require_full_window = false
|
||||||
new_host_delay = "${var.new_host_delay}"
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
|
||||||
tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.no_connection_extra_tags}"]
|
tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:mysql", "team:claranet", "created-by:terraform", "${var.total_connection_extra_tags}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "datadog_monitor" "mysql_free_storage" {
|
resource "datadog_monitor" "mysql_free_storage" {
|
||||||
|
|||||||
@ -3,9 +3,9 @@ output "mysql_cpu_usage_id" {
|
|||||||
value = "${datadog_monitor.mysql_cpu_usage.*.id}"
|
value = "${datadog_monitor.mysql_cpu_usage.*.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "mysql_no_connection_id" {
|
output "mysql_total_connection_id" {
|
||||||
description = "id for monitor mysql_no_connection"
|
description = "id for monitor mysql_total_connection"
|
||||||
value = "${datadog_monitor.mysql_no_connection.*.id}"
|
value = "${datadog_monitor.mysql_total_connection.*.id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "mysql_free_storage_id" {
|
output "mysql_free_storage_id" {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user