Merged in MON-246-add-monitors-for-azure-mysql (pull request #167)
MON-246 Monitors for Azure MySQL Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr> Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
This commit is contained in:
commit
7da2ecf68c
@ -101,6 +101,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
||||
- [eventhub](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/eventhub/)
|
||||
- [iothubs](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/iothubs/)
|
||||
- [keyvault](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/keyvault/)
|
||||
- [mysql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/mysql/)
|
||||
- [postgresql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/postgresql/)
|
||||
- [redis](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/redis/)
|
||||
- [serverfarms](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/serverfarms/)
|
||||
|
||||
101
cloud/azure/mysql/README.md
Normal file
101
cloud/azure/mysql/README.md
Normal file
@ -0,0 +1,101 @@
|
||||
# CLOUD AZURE MYSQL DataDog monitors
|
||||
|
||||
## How to use this module
|
||||
|
||||
```
|
||||
module "datadog-monitors-cloud-azure-mysql" {
|
||||
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/mysql?ref={revision}"
|
||||
|
||||
environment = "${var.environment}"
|
||||
message = "${module.datadog-message-alerting.alerting-message}"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
Creates DataDog monitors with the following checks:
|
||||
|
||||
- Mysql Server compute consumption
|
||||
- Mysql Server CPU usage
|
||||
- Mysql Server has no connection
|
||||
- Mysql Server IO consumption
|
||||
- Mysql Server memory usage
|
||||
- Mysql Server storage
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| compute_consumption_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||
| compute_consumption_extra_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
||||
| compute_consumption_message | Custom message for Mysql compute consumption monitor | string | `` | no |
|
||||
| compute_consumption_silenced | Groups to mute for Mysql compute consumption monitor | map | `{}` | no |
|
||||
| compute_consumption_threshold_critical | Mysql compute consumption in percent (critical threshold) | string | `90` | no |
|
||||
| compute_consumption_threshold_warning | Mysql compute consumption in percent (warning threshold) | string | `80` | no |
|
||||
| compute_consumption_time_aggregator | Monitor aggregator for Mysql compute consumption [available values: min, max or avg] | string | `min` | no |
|
||||
| compute_consumption_timeframe | Monitor timeframe for Mysql compute consumption [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_enabled | Flag to enable Mysql status monitor | string | `true` | no |
|
||||
| cpu_usage_extra_tags | Extra tags for Mysql status monitor | list | `[]` | 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_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_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 |
|
||||
| environment | Architecture environment | string | - | yes |
|
||||
| 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_use_defaults | Use default filter tags convention | 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_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_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_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 |
|
||||
| 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_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_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_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 |
|
||||
| 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_message | Custom message for Mysql memory monitor | string | `` | no |
|
||||
| memory_usage_silenced | Groups to mute for Mysql memory monitor | map | `{}` | 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_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 |
|
||||
| message | Message sent when an alert is triggered | string | - | yes |
|
||||
| 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 |
|
||||
| no_connection_extra_tags | Extra tags for Mysql status monitor | list | `[]` | no |
|
||||
| no_connection_message | Custom message for Mysql no connection monitor | string | `` | no |
|
||||
| no_connection_silenced | Groups to mute for Mysql no connection monitor | map | `{}` | no |
|
||||
| no_connection_time_aggregator | Monitor aggregator for Mysql no connection [available values: min, max or avg] | string | `min` | 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 |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| mysql_compute_consumption_id | id for monitor mysql_compute_consumption |
|
||||
| mysql_cpu_usage_id | id for monitor mysql_cpu_usage |
|
||||
| mysql_free_storage_id | id for monitor mysql_free_storage |
|
||||
| mysql_io_consumption_id | id for monitor mysql_io_consumption |
|
||||
| mysql_memory_usage_id | id for monitor mysql_memory_usage |
|
||||
| mysql_no_connection_id | id for monitor mysql_no_connection |
|
||||
|
||||
Related documentation
|
||||
---------------------
|
||||
|
||||
DataDog documentation: [https://docs.datadoghq.com/integrations/azure/](https://docs.datadoghq.com/integrations/azure/)
|
||||
You have to search `mysql`
|
||||
|
||||
Azure Database for MySQL servers metrics documentation: [https://docs.microsoft.com/en-us/azure/mysql/concepts-monitoring](https://docs.microsoft.com/en-us/azure/mysql/concepts-monitoring)
|
||||
|
||||
297
cloud/azure/mysql/inputs.tf
Normal file
297
cloud/azure/mysql/inputs.tf
Normal file
@ -0,0 +1,297 @@
|
||||
# Global Terraform
|
||||
variable "environment" {
|
||||
description = "Architecture environment"
|
||||
type = "string"
|
||||
}
|
||||
|
||||
# Global DataDog
|
||||
variable "evaluation_delay" {
|
||||
description = "Delay in seconds for the metric evaluation"
|
||||
default = 900
|
||||
}
|
||||
|
||||
variable "new_host_delay" {
|
||||
description = "Delay in seconds before monitor new resource"
|
||||
default = 300
|
||||
}
|
||||
|
||||
variable "message" {
|
||||
description = "Message sent when an alert is triggered"
|
||||
}
|
||||
|
||||
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 Databases for MySQL Servers specific variables
|
||||
variable "cpu_usage_silenced" {
|
||||
description = "Groups to mute for Mysql CPU monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "cpu_usage_enabled" {
|
||||
description = "Flag to enable Mysql status monitor"
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "cpu_usage_extra_tags" {
|
||||
description = "Extra tags for Mysql status monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "cpu_usage_message" {
|
||||
description = "Custom message for Mysql CPU monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cpu_usage_time_aggregator" {
|
||||
description = "Monitor aggregator for Mysql CPU [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "cpu_usage_timeframe" {
|
||||
description = "Monitor timeframe for Mysql CPU [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "cpu_usage_threshold_warning" {
|
||||
description = "Mysql CPU usage in percent (warning threshold)"
|
||||
default = "80"
|
||||
}
|
||||
|
||||
variable "cpu_usage_threshold_critical" {
|
||||
description = "Mysql CPU usage in percent (critical threshold)"
|
||||
default = "90"
|
||||
}
|
||||
|
||||
variable "no_connection_silenced" {
|
||||
description = "Groups to mute for Mysql no connection monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "no_connection_enabled" {
|
||||
description = "Flag to enable Mysql status monitor"
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "no_connection_extra_tags" {
|
||||
description = "Extra tags for Mysql status monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "no_connection_message" {
|
||||
description = "Custom message for Mysql no connection monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "no_connection_time_aggregator" {
|
||||
description = "Monitor aggregator for Mysql no connection [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "no_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`]"
|
||||
type = "string"
|
||||
default = "last_5m"
|
||||
}
|
||||
|
||||
variable "free_storage_silenced" {
|
||||
description = "Groups to mute for Mysql Free Storage monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "free_storage_enabled" {
|
||||
description = "Flag to enable Mysql status monitor"
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "free_storage_extra_tags" {
|
||||
description = "Extra tags for Mysql status monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "free_storage_message" {
|
||||
description = "Custom message for Mysql Free Storage monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "free_storage_time_aggregator" {
|
||||
description = "Monitor aggregator for Mysql Free Storage [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "free_storage_timeframe" {
|
||||
description = "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`]"
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "free_storage_threshold_warning" {
|
||||
description = "Mysql Free Storage remaining in percent (warning threshold)"
|
||||
default = "20"
|
||||
}
|
||||
|
||||
variable "free_storage_threshold_critical" {
|
||||
description = "Mysql Free Storage remaining in percent (critical threshold)"
|
||||
default = "10"
|
||||
}
|
||||
|
||||
variable "io_consumption_silenced" {
|
||||
description = "Groups to mute for Mysql IO consumption monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "io_consumption_enabled" {
|
||||
description = "Flag to enable Mysql status monitor"
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "io_consumption_extra_tags" {
|
||||
description = "Extra tags for Mysql status monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "io_consumption_message" {
|
||||
description = "Custom message for Mysql IO consumption monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "io_consumption_time_aggregator" {
|
||||
description = "Monitor aggregator for Mysql IO consumption [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "io_consumption_timeframe" {
|
||||
description = "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`]"
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "io_consumption_threshold_warning" {
|
||||
description = "Mysql IO consumption in percent (warning threshold)"
|
||||
default = "80"
|
||||
}
|
||||
|
||||
variable "io_consumption_threshold_critical" {
|
||||
description = "Mysql IO consumption in percent (critical threshold)"
|
||||
default = "90"
|
||||
}
|
||||
|
||||
variable "compute_consumption_silenced" {
|
||||
description = "Groups to mute for Mysql compute consumption monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "compute_consumption_enabled" {
|
||||
description = "Flag to enable Mysql status monitor"
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "compute_consumption_extra_tags" {
|
||||
description = "Extra tags for Mysql status monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "compute_consumption_message" {
|
||||
description = "Custom message for Mysql compute consumption monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "compute_consumption_time_aggregator" {
|
||||
description = "Monitor aggregator for Mysql compute consumption [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "compute_consumption_timeframe" {
|
||||
description = "Monitor timeframe for Mysql compute consumption [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "compute_consumption_threshold_warning" {
|
||||
description = "Mysql compute consumption in percent (warning threshold)"
|
||||
default = "80"
|
||||
}
|
||||
|
||||
variable "compute_consumption_threshold_critical" {
|
||||
description = "Mysql compute consumption in percent (critical threshold)"
|
||||
default = "90"
|
||||
}
|
||||
|
||||
variable "memory_usage_silenced" {
|
||||
description = "Groups to mute for Mysql memory monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "memory_usage_enabled" {
|
||||
description = "Flag to enable Mysql status monitor"
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "memory_usage_extra_tags" {
|
||||
description = "Extra tags for Mysql status monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "memory_usage_message" {
|
||||
description = "Custom message for Mysql memory monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "memory_usage_time_aggregator" {
|
||||
description = "Monitor aggregator for Mysql memory [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "memory_usage_timeframe" {
|
||||
description = "Monitor timeframe for Mysql memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "memory_usage_threshold_warning" {
|
||||
description = "Mysql memory usage in percent (warning threshold)"
|
||||
default = "80"
|
||||
}
|
||||
|
||||
variable "memory_usage_threshold_critical" {
|
||||
description = "Mysql memory usage in percent (critical threshold)"
|
||||
default = "90"
|
||||
}
|
||||
8
cloud/azure/mysql/modules.tf
Normal file
8
cloud/azure/mysql/modules.tf
Normal file
@ -0,0 +1,8 @@
|
||||
module "filter-tags" {
|
||||
source = "../../../common/filter-tags"
|
||||
|
||||
environment = "${var.environment}"
|
||||
resource = "mysql"
|
||||
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||
filter_tags_custom = "${var.filter_tags_custom}"
|
||||
}
|
||||
192
cloud/azure/mysql/monitors-mysql.tf
Normal file
192
cloud/azure/mysql/monitors-mysql.tf
Normal file
@ -0,0 +1,192 @@
|
||||
resource "datadog_monitor" "mysql_cpu_usage" {
|
||||
count = "${var.cpu_usage_enabled ? 1 : 0}"
|
||||
name = "[${var.environment}] Mysql Server CPU usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.cpu_usage_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
${var.cpu_usage_time_aggregator}(${var.cpu_usage_timeframe}): (
|
||||
avg:azure.dbformysql_servers.cpu_percent${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||
) > ${var.cpu_usage_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.cpu_usage_threshold_critical}"
|
||||
warning = "${var.cpu_usage_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.cpu_usage_silenced}"
|
||||
|
||||
notify_no_data = false
|
||||
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:mysql", "team:claranet", "created-by:terraform", "${var.cpu_usage_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_no_connection" {
|
||||
count = "${var.no_connection_enabled ? 1 : 0}"
|
||||
name = "[${var.environment}] Mysql Server has no connection"
|
||||
message = "${coalesce(var.no_connection_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
${var.no_connection_time_aggregator}(${var.no_connection_timeframe}): (
|
||||
avg:azure.dbformysql_servers.active_connections${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||
) < 1
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
silenced = "${var.no_connection_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:mysql", "team:claranet", "created-by:terraform", "${var.no_connection_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_free_storage" {
|
||||
count = "${var.free_storage_enabled ? 1 : 0}"
|
||||
name = "[${var.environment}] Mysql Server storage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.free_storage_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
${var.free_storage_time_aggregator}(${var.free_storage_timeframe}): (
|
||||
100 - avg:azure.dbformysql_servers.storage_percent${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||
) < ${var.free_storage_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.free_storage_threshold_critical}"
|
||||
warning = "${var.free_storage_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.free_storage_silenced}"
|
||||
|
||||
notify_no_data = false
|
||||
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:mysql", "team:claranet", "created-by:terraform", "${var.free_storage_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_io_consumption" {
|
||||
count = "${var.io_consumption_enabled ? 1 : 0}"
|
||||
name = "[${var.environment}] Mysql Server IO consumption {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.io_consumption_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
${var.io_consumption_time_aggregator}(${var.io_consumption_timeframe}): (
|
||||
avg:azure.dbformysql_servers.io_consumption_percent${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||
) > ${var.io_consumption_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.io_consumption_threshold_critical}"
|
||||
warning = "${var.io_consumption_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.io_consumption_silenced}"
|
||||
|
||||
notify_no_data = false
|
||||
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:mysql", "team:claranet", "created-by:terraform", "${var.io_consumption_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_compute_consumption" {
|
||||
count = "${var.compute_consumption_enabled ? 1 : 0}"
|
||||
name = "[${var.environment}] Mysql Server compute consumption {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.compute_consumption_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
${var.compute_consumption_time_aggregator}(${var.compute_consumption_timeframe}): (
|
||||
avg:azure.dbformysql_servers.compute_consumption_percent${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||
) > ${var.compute_consumption_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.compute_consumption_threshold_critical}"
|
||||
warning = "${var.compute_consumption_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.compute_consumption_silenced}"
|
||||
|
||||
notify_no_data = false
|
||||
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:mysql", "team:claranet", "created-by:terraform", "${var.compute_consumption_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_memory_usage" {
|
||||
count = "${var.memory_usage_enabled ? 1 : 0}"
|
||||
name = "[${var.environment}] Mysql Server memory usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.memory_usage_message, var.message)}"
|
||||
|
||||
query = <<EOF
|
||||
${var.memory_usage_time_aggregator}(${var.memory_usage_timeframe}): (
|
||||
avg:azure.dbformysql_servers.memory_percent${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||
) > ${var.memory_usage_threshold_critical}
|
||||
EOF
|
||||
|
||||
type = "metric alert"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.memory_usage_threshold_critical}"
|
||||
warning = "${var.memory_usage_threshold_warning}"
|
||||
}
|
||||
|
||||
silenced = "${var.memory_usage_silenced}"
|
||||
|
||||
notify_no_data = false
|
||||
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:mysql", "team:claranet", "created-by:terraform", "${var.memory_usage_extra_tags}"]
|
||||
}
|
||||
29
cloud/azure/mysql/outputs.tf
Normal file
29
cloud/azure/mysql/outputs.tf
Normal file
@ -0,0 +1,29 @@
|
||||
output "mysql_cpu_usage_id" {
|
||||
description = "id for monitor mysql_cpu_usage"
|
||||
value = "${datadog_monitor.mysql_cpu_usage.*.id}"
|
||||
}
|
||||
|
||||
output "mysql_no_connection_id" {
|
||||
description = "id for monitor mysql_no_connection"
|
||||
value = "${datadog_monitor.mysql_no_connection.*.id}"
|
||||
}
|
||||
|
||||
output "mysql_free_storage_id" {
|
||||
description = "id for monitor mysql_free_storage"
|
||||
value = "${datadog_monitor.mysql_free_storage.*.id}"
|
||||
}
|
||||
|
||||
output "mysql_io_consumption_id" {
|
||||
description = "id for monitor mysql_io_consumption"
|
||||
value = "${datadog_monitor.mysql_io_consumption.*.id}"
|
||||
}
|
||||
|
||||
output "mysql_compute_consumption_id" {
|
||||
description = "id for monitor mysql_compute_consumption"
|
||||
value = "${datadog_monitor.mysql_compute_consumption.*.id}"
|
||||
}
|
||||
|
||||
output "mysql_memory_usage_id" {
|
||||
description = "id for monitor mysql_memory_usage"
|
||||
value = "${datadog_monitor.mysql_memory_usage.*.id}"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user