Merged in MON-142-monitors-for-mysql (pull request #65)
MON-142: Monitor for MySQL Approved-by: Boris Rousseau <boris.rousseau@morea.fr> Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net> Approved-by: Patrick Decat <patrick.decat@fr.clara.net> Approved-by: Laurent Piroelle <laurent.piroelle@fr.clara.net> Approved-by: Jérôme Respaut <shr3ps@gmail.com> Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr>
This commit is contained in:
commit
348d112b35
@ -102,6 +102,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
||||
- [filter-tags](https://bitbucket.org/morea/terraform.feature.datadog/src/master/common/filter-tags/)
|
||||
- [database](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/)
|
||||
- [mongodb](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/mongodb/)
|
||||
- [mysql](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/mysql/)
|
||||
- [redis](https://bitbucket.org/morea/terraform.feature.datadog/src/master/database/redis/)
|
||||
- [middleware](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/)
|
||||
- [apache](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/apache/)
|
||||
|
||||
120
database/mysql/README.md
Normal file
120
database/mysql/README.md
Normal file
@ -0,0 +1,120 @@
|
||||
# DATABASE MYSQL DataDog monitors
|
||||
|
||||
## How to use this module
|
||||
|
||||
```
|
||||
module "datadog-monitors-database-mysql" {
|
||||
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//database/mysql?ref={revision}"
|
||||
|
||||
environment = "${var.environment}"
|
||||
message = "${module.datadog-message-alerting.alerting-message}"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
Creates DataDog monitors with the following checks:
|
||||
|
||||
- Mysql server does not respond
|
||||
- Mysql Connections limit
|
||||
- Mysql Aborted connects
|
||||
- Mysql Slow queries
|
||||
- Mysql Innodb buffer pool efficiency
|
||||
- Mysql Innodb buffer pool utilization
|
||||
- Mysql threads changed abnormally
|
||||
- Mysql queries changed abnormally
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| environment | Environment | string | - | yes |
|
||||
| evaluation_delay | Delay in seconds for the metric evaluation | string | `15` | 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 |
|
||||
| message | Message sent when an alert is triggered | string | - | yes |
|
||||
| mysql_aborted_extra_tags | Extra tags for MySQL aborted connects monitor | list | `<list>` | no |
|
||||
| mysql_aborted_message | Custom message for MySQL aborted connects monitor | string | `` | no |
|
||||
| mysql_aborted_silenced | Groups to mute MySQL aborted connects monitor | map | `<map>` | no |
|
||||
| mysql_aborted_threshold_critical | Maximum critical acceptable percent of aborted connects | string | `10` | no |
|
||||
| mysql_aborted_threshold_warning | Maximum warning acceptable percent of aborted connects | string | `5` | no |
|
||||
| mysql_aborted_time_aggregator | Monitor time aggregator for MySQL aborted connects monitor [available values: min, max or avg] | string | `avg` | no |
|
||||
| mysql_aborted_timeframe | Monitor timeframe for MySQL aborted connects monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_10m` | no |
|
||||
| mysql_availability_extra_tags | Extra tags for Mysql availability monitor | list | `<list>` | no |
|
||||
| mysql_availability_message | Custom message for Mysql availability monitor | string | `` | no |
|
||||
| mysql_availability_silenced | Groups to mute for Mysql availability monitor | map | `<map>` | no |
|
||||
| mysql_availability_threshold_critical | Mysql availability monitor (critical threshold) | string | `1.1754943508222875e-38` | no |
|
||||
| mysql_connection_extra_tags | Extra tags for MySQL connection monitor | list | `<list>` | no |
|
||||
| mysql_connection_message | Custom message for MySQL connection monitor | string | `` | no |
|
||||
| mysql_connection_silenced | Groups to mute MySQL connection monitor | map | `<map>` | no |
|
||||
| mysql_connection_threshold_critical | Maximum critical acceptable percent of connections | string | `80` | no |
|
||||
| mysql_connection_threshold_warning | Maximum warning acceptable percent of connections | string | `70` | no |
|
||||
| mysql_connection_time_aggregator | Monitor time aggregator for MySQL connection monitor [available values: min, max or avg] | string | `avg` | no |
|
||||
| mysql_connection_timeframe | Monitor timeframe for MySQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_10m` | no |
|
||||
| mysql_pool_efficiency_extra_tags | Extra tags for MySQL innodb buffer pool efficiency monitor | list | `<list>` | no |
|
||||
| mysql_pool_efficiency_message | Custom message for MySQL innodb buffer pool efficiency monitor | string | `` | no |
|
||||
| mysql_pool_efficiency_silenced | Groups to mute MySQL innodb buffer pool efficiency monitor | map | `<map>` | no |
|
||||
| mysql_pool_efficiency_threshold_critical | Maximum critical acceptable percent of innodb buffer pool efficiency | string | `20` | no |
|
||||
| mysql_pool_efficiency_threshold_warning | Maximum warning acceptable percent of innodb buffer pool efficiency | string | `1` | no |
|
||||
| mysql_pool_efficiency_time_aggregator | Monitor time aggregator for MySQL innodb buffer pool efficiency monitor [available values: min, max or avg] | string | `sum` | no |
|
||||
| mysql_pool_efficiency_timeframe | Monitor timeframe for MySQL innodb buffer pool efficiency monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_1h` | no |
|
||||
| mysql_pool_utilization_extra_tags | Extra tags for MySQL innodb buffer pool utilization monitor | list | `<list>` | no |
|
||||
| mysql_pool_utilization_message | Custom message for MySQL innodb buffer pool utilization monitor | string | `` | no |
|
||||
| mysql_pool_utilization_silenced | Groups to mute MySQL innodb buffer pool utilization monitor | map | `<map>` | no |
|
||||
| mysql_pool_utilization_threshold_critical | Maximum critical acceptable percent of innodb buffer pool utilization | string | `90` | no |
|
||||
| mysql_pool_utilization_threshold_warning | Maximum warning acceptable percent of innodb buffer pool utilization | string | `75` | no |
|
||||
| mysql_pool_utilization_time_aggregator | Monitor time aggregator for MySQL innodb buffer pool utilization monitor [available values: min, max or avg] | string | `min` | no |
|
||||
| mysql_pool_utilization_timeframe | Monitor timeframe for MySQL innodb buffer pool utilization monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_4h` | no |
|
||||
| mysql_queries_alert_window | Alert window. | string | `last_15m` | no |
|
||||
| mysql_queries_count_default_zero | Count default zero. | string | `true` | no |
|
||||
| mysql_queries_detection_algorithm | Anomaly Detection Algorithm used | string | `agile` | no |
|
||||
| mysql_queries_deviations | Deviations to detect the anomaly | string | `5` | no |
|
||||
| mysql_queries_direction | Direction of the anomaly. It can be both, below or above. | string | `both` | no |
|
||||
| mysql_queries_extra_tags | Extra tags for MySQL queries monitor | list | `<list>` | no |
|
||||
| mysql_queries_interval | Interval. | string | `60` | no |
|
||||
| mysql_queries_message | Custom message for MySQL queries monitor | string | `` | no |
|
||||
| mysql_queries_seasonality | Seasonality of the algorithm | string | `daily` | no |
|
||||
| mysql_queries_silenced | Groups to mute mysql queries monitor | map | `<map>` | no |
|
||||
| mysql_queries_threshold_critical | Maximum critical acceptable number of queries | string | `1` | no |
|
||||
| mysql_queries_time_aggregator | Monitor time aggregator for MySQL queries monitor [available values: min, max or avg] | string | `avg` | no |
|
||||
| mysql_queries_timeframe | Monitor timeframe for MySQL queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_4h` | no |
|
||||
| mysql_slow_extra_tags | Extra tags for MySQL slow queries monitor | list | `<list>` | no |
|
||||
| mysql_slow_message | Custom message for MySQL slow queries monitor | string | `` | no |
|
||||
| mysql_slow_silenced | Groups to mute MySQL slow queries monitor | map | `<map>` | no |
|
||||
| mysql_slow_threshold_critical | Maximum critical acceptable percent of slow queries | string | `20` | no |
|
||||
| mysql_slow_threshold_warning | Maximum warning acceptable percent of slow queries | string | `5` | no |
|
||||
| mysql_slow_time_aggregator | Monitor time aggregator for MySQL slow queries monitor [available values: min, max or avg] | string | `avg` | no |
|
||||
| mysql_slow_timeframe | Monitor timeframe for MySQL slow queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no |
|
||||
| mysql_threads_alert_window | Alert window. | string | `last_15m` | no |
|
||||
| mysql_threads_count_default_zero | Count default zero. | string | `true` | no |
|
||||
| mysql_threads_detection_algorithm | Anomaly Detection Algorithm used | string | `basic` | no |
|
||||
| mysql_threads_deviations | Deviations to detect the anomaly | string | `2` | no |
|
||||
| mysql_threads_direction | Direction of the anomaly. It can be both, below or above. | string | `above` | no |
|
||||
| mysql_threads_extra_tags | Extra tags for MySQL threads monitor | list | `<list>` | no |
|
||||
| mysql_threads_interval | Interval. | string | `60` | no |
|
||||
| mysql_threads_message | Custom message for MySQL threads monitor | string | `` | no |
|
||||
| mysql_threads_seasonality | Seasonality of the algorithm | string | `daily` | no |
|
||||
| mysql_threads_silenced | Groups to mute mysql threads monitor | map | `<map>` | no |
|
||||
| mysql_threads_threshold_critical | Maximum critical acceptable number of threads | string | `1` | no |
|
||||
| mysql_threads_time_aggregator | Monitor time aggregator for MySQL threads monitor [available values: min, max or avg] | string | `avg` | no |
|
||||
| mysql_threads_timeframe | Monitor timeframe for MySQL threads monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_4h` | no |
|
||||
| new_host_delay | Delay in seconds for the metric evaluation | string | `300` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| mysql_aborted_id | id for monitor mysql_aborted |
|
||||
| mysql_availability_id | id for monitor mysql_availability |
|
||||
| mysql_connection_id | id for monitor mysql_connection |
|
||||
| mysql_pool_efficiency_id | id for monitor mysql_pool_efficiency |
|
||||
| mysql_pool_utilization_id | id for monitor mysql_pool_utilization |
|
||||
| mysql_queries_anomaly_id | id for monitor mysql_queries_anomaly |
|
||||
| mysql_slow_id | id for monitor mysql_slow |
|
||||
| mysql_threads_anomaly_id | id for monitor mysql_threads_anomaly |
|
||||
|
||||
Related documentation
|
||||
---------------------
|
||||
|
||||
DataDog documentation: [https://docs.datadoghq.com/integrations/mysql/](https://docs.datadoghq.com/integrations/mysql/)
|
||||
440
database/mysql/inputs.tf
Normal file
440
database/mysql/inputs.tf
Normal file
@ -0,0 +1,440 @@
|
||||
variable "environment" {
|
||||
description = "Environment"
|
||||
type = "string"
|
||||
}
|
||||
|
||||
variable "evaluation_delay" {
|
||||
description = "Delay in seconds for the metric evaluation"
|
||||
default = 15
|
||||
}
|
||||
|
||||
variable "new_host_delay" {
|
||||
description = "Delay in seconds for the metric evaluation"
|
||||
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 = "*"
|
||||
}
|
||||
|
||||
# MySQL specific
|
||||
|
||||
#################################
|
||||
### MySQL availability ###
|
||||
#################################
|
||||
|
||||
variable "mysql_availability_silenced" {
|
||||
description = "Groups to mute for Mysql availability monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_availability_extra_tags" {
|
||||
description = "Extra tags for Mysql availability monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "mysql_availability_message" {
|
||||
description = "Custom message for Mysql availability monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_availability_threshold_critical" {
|
||||
description = "Mysql availability monitor (critical threshold)"
|
||||
type = "string"
|
||||
default = 1.1754943508222875e-38
|
||||
}
|
||||
|
||||
#################################
|
||||
### MySQL connections ###
|
||||
#################################
|
||||
|
||||
variable "mysql_connection_threshold_critical" {
|
||||
default = 80
|
||||
description = "Maximum critical acceptable percent of connections"
|
||||
}
|
||||
|
||||
variable "mysql_connection_threshold_warning" {
|
||||
default = 70
|
||||
description = "Maximum warning acceptable percent of connections"
|
||||
}
|
||||
|
||||
variable "mysql_connection_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL connection monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "avg"
|
||||
}
|
||||
|
||||
variable "mysql_connection_timeframe" {
|
||||
description = "Monitor timeframe for MySQL connection monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_10m"
|
||||
}
|
||||
|
||||
variable "mysql_connection_silenced" {
|
||||
description = "Groups to mute MySQL connection monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_connection_message" {
|
||||
description = "Custom message for MySQL connection monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_connection_extra_tags" {
|
||||
description = "Extra tags for MySQL connection monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
#################################
|
||||
### MySQL aborted connects ###
|
||||
#################################
|
||||
|
||||
variable "mysql_aborted_threshold_critical" {
|
||||
default = 10
|
||||
description = "Maximum critical acceptable percent of aborted connects"
|
||||
}
|
||||
|
||||
variable "mysql_aborted_threshold_warning" {
|
||||
default = 5
|
||||
description = "Maximum warning acceptable percent of aborted connects"
|
||||
}
|
||||
|
||||
variable "mysql_aborted_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL aborted connects monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "avg"
|
||||
}
|
||||
|
||||
variable "mysql_aborted_timeframe" {
|
||||
description = "Monitor timeframe for MySQL aborted connects monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_10m"
|
||||
}
|
||||
|
||||
variable "mysql_aborted_silenced" {
|
||||
description = "Groups to mute MySQL aborted connects monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_aborted_message" {
|
||||
description = "Custom message for MySQL aborted connects monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_aborted_extra_tags" {
|
||||
description = "Extra tags for MySQL aborted connects monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
#################################
|
||||
### MySQL slow queries ###
|
||||
#################################
|
||||
|
||||
variable "mysql_slow_threshold_critical" {
|
||||
default = 20
|
||||
description = "Maximum critical acceptable percent of slow queries"
|
||||
}
|
||||
|
||||
variable "mysql_slow_threshold_warning" {
|
||||
default = 5
|
||||
description = "Maximum warning acceptable percent of slow queries"
|
||||
}
|
||||
|
||||
variable "mysql_slow_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL slow queries monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "avg"
|
||||
}
|
||||
|
||||
variable "mysql_slow_timeframe" {
|
||||
description = "Monitor timeframe for MySQL slow queries monitor [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 "mysql_slow_silenced" {
|
||||
description = "Groups to mute MySQL slow queries monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_slow_message" {
|
||||
description = "Custom message for MySQL slow queries monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_slow_extra_tags" {
|
||||
description = "Extra tags for MySQL slow queries monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
#################################
|
||||
# MySQL innodb pool efficiency #
|
||||
#################################
|
||||
|
||||
variable "mysql_pool_efficiency_threshold_critical" {
|
||||
default = 20
|
||||
description = "Maximum critical acceptable percent of innodb buffer pool efficiency"
|
||||
}
|
||||
|
||||
variable "mysql_pool_efficiency_threshold_warning" {
|
||||
default = 1
|
||||
description = "Maximum warning acceptable percent of innodb buffer pool efficiency"
|
||||
}
|
||||
|
||||
variable "mysql_pool_efficiency_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL innodb buffer pool efficiency monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "sum"
|
||||
}
|
||||
|
||||
variable "mysql_pool_efficiency_timeframe" {
|
||||
description = "Monitor timeframe for MySQL innodb buffer pool efficiency monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_1h"
|
||||
}
|
||||
|
||||
variable "mysql_pool_efficiency_silenced" {
|
||||
description = "Groups to mute MySQL innodb buffer pool efficiency monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_pool_efficiency_message" {
|
||||
description = "Custom message for MySQL innodb buffer pool efficiency monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_pool_efficiency_extra_tags" {
|
||||
description = "Extra tags for MySQL innodb buffer pool efficiency monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
#################################
|
||||
# MySQL innodb pool utilization #
|
||||
#################################
|
||||
|
||||
variable "mysql_pool_utilization_threshold_critical" {
|
||||
default = 90
|
||||
description = "Maximum critical acceptable percent of innodb buffer pool utilization"
|
||||
}
|
||||
|
||||
variable "mysql_pool_utilization_threshold_warning" {
|
||||
default = 75
|
||||
description = "Maximum warning acceptable percent of innodb buffer pool utilization"
|
||||
}
|
||||
|
||||
variable "mysql_pool_utilization_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL innodb buffer pool utilization monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "mysql_pool_utilization_timeframe" {
|
||||
description = "Monitor timeframe for MySQL innodb buffer pool utilization monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_4h"
|
||||
}
|
||||
|
||||
variable "mysql_pool_utilization_silenced" {
|
||||
description = "Groups to mute MySQL innodb buffer pool utilization monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_pool_utilization_message" {
|
||||
description = "Custom message for MySQL innodb buffer pool utilization monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_pool_utilization_extra_tags" {
|
||||
description = "Extra tags for MySQL innodb buffer pool utilization monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
#################################
|
||||
### MySQL threads ###
|
||||
#################################
|
||||
|
||||
variable "mysql_threads_threshold_critical" {
|
||||
default = 1
|
||||
description = "Maximum critical acceptable number of threads"
|
||||
}
|
||||
|
||||
variable "mysql_threads_detection_algorithm" {
|
||||
description = "Anomaly Detection Algorithm used"
|
||||
type = "string"
|
||||
default = "basic"
|
||||
}
|
||||
|
||||
variable "mysql_threads_deviations" {
|
||||
description = "Deviations to detect the anomaly"
|
||||
type = "string"
|
||||
default = 2
|
||||
}
|
||||
|
||||
variable "mysql_threads_direction" {
|
||||
description = "Direction of the anomaly. It can be both, below or above."
|
||||
type = "string"
|
||||
default = "above"
|
||||
}
|
||||
|
||||
variable "mysql_threads_alert_window" {
|
||||
description = "Alert window."
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "mysql_threads_interval" {
|
||||
description = "Interval."
|
||||
type = "string"
|
||||
default = 60
|
||||
}
|
||||
|
||||
variable "mysql_threads_count_default_zero" {
|
||||
description = "Count default zero."
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "mysql_threads_seasonality" {
|
||||
description = "Seasonality of the algorithm"
|
||||
type = "string"
|
||||
default = "daily"
|
||||
}
|
||||
|
||||
variable "mysql_threads_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL threads monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "avg"
|
||||
}
|
||||
|
||||
variable "mysql_threads_timeframe" {
|
||||
description = "Monitor timeframe for MySQL threads monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_4h"
|
||||
}
|
||||
|
||||
variable "mysql_threads_silenced" {
|
||||
description = "Groups to mute mysql threads monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_threads_message" {
|
||||
description = "Custom message for MySQL threads monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_threads_extra_tags" {
|
||||
description = "Extra tags for MySQL threads monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
|
||||
#################################
|
||||
### MySQL queries ###
|
||||
#################################
|
||||
|
||||
variable "mysql_queries_threshold_critical" {
|
||||
default = 1
|
||||
description = "Maximum critical acceptable number of queries"
|
||||
}
|
||||
|
||||
variable "mysql_queries_detection_algorithm" {
|
||||
description = "Anomaly Detection Algorithm used"
|
||||
type = "string"
|
||||
default = "agile"
|
||||
}
|
||||
|
||||
variable "mysql_queries_deviations" {
|
||||
description = "Deviations to detect the anomaly"
|
||||
type = "string"
|
||||
default = 5
|
||||
}
|
||||
|
||||
variable "mysql_queries_direction" {
|
||||
description = "Direction of the anomaly. It can be both, below or above."
|
||||
type = "string"
|
||||
default = "both"
|
||||
}
|
||||
|
||||
variable "mysql_queries_alert_window" {
|
||||
description = "Alert window."
|
||||
type = "string"
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "mysql_queries_interval" {
|
||||
description = "Interval."
|
||||
type = "string"
|
||||
default = 60
|
||||
}
|
||||
|
||||
variable "mysql_queries_count_default_zero" {
|
||||
description = "Count default zero."
|
||||
type = "string"
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "mysql_queries_seasonality" {
|
||||
description = "Seasonality of the algorithm"
|
||||
type = "string"
|
||||
default = "daily"
|
||||
}
|
||||
|
||||
variable "mysql_queries_time_aggregator" {
|
||||
description = "Monitor time aggregator for MySQL queries monitor [available values: min, max or avg]"
|
||||
type = "string"
|
||||
default = "avg"
|
||||
}
|
||||
|
||||
variable "mysql_queries_timeframe" {
|
||||
description = "Monitor timeframe for MySQL queries monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = "string"
|
||||
default = "last_4h"
|
||||
}
|
||||
|
||||
variable "mysql_queries_silenced" {
|
||||
description = "Groups to mute mysql queries monitor"
|
||||
type = "map"
|
||||
default = {}
|
||||
}
|
||||
|
||||
variable "mysql_queries_message" {
|
||||
description = "Custom message for MySQL queries monitor"
|
||||
type = "string"
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "mysql_queries_extra_tags" {
|
||||
description = "Extra tags for MySQL queries monitor"
|
||||
type = "list"
|
||||
default = []
|
||||
}
|
||||
8
database/mysql/modules.tf
Normal file
8
database/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}"
|
||||
}
|
||||
262
database/mysql/monitors-mysql.tf
Normal file
262
database/mysql/monitors-mysql.tf
Normal file
@ -0,0 +1,262 @@
|
||||
resource "datadog_monitor" "mysql_availability" {
|
||||
name = "[${var.environment}] Mysql server does not respond"
|
||||
message = "${coalesce(var.mysql_availability_message, var.message)}"
|
||||
|
||||
type = "service check"
|
||||
|
||||
query = <<EOF
|
||||
"mysql.can_connect".over${module.filter-tags.service_check}.by("host","port","server").last(1).pct_by_status()
|
||||
EOF
|
||||
|
||||
thresholds = {
|
||||
warning = 0
|
||||
critical = "${var.mysql_availability_threshold_critical}"
|
||||
}
|
||||
|
||||
notify_no_data = true
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
renotify_interval = 0
|
||||
notify_audit = false
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
locked = false
|
||||
require_full_window = true
|
||||
|
||||
silenced = "${var.mysql_availability_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_connection" {
|
||||
name = "[${var.environment}] Mysql Connections limit {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.mysql_connection_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_connection_time_aggregator}(${var.mysql_connection_timeframe}): (
|
||||
avg:mysql.net.connections${module.filter-tags.query_alert} by {server} /
|
||||
avg:mysql.net.max_connections_available${module.filter-tags.query_alert} by {server}
|
||||
) * 100 > ${var.mysql_connection_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
warning = "${var.mysql_connection_threshold_warning}"
|
||||
critical = "${var.mysql_connection_threshold_critical}"
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_connection_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_connection_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_aborted" {
|
||||
name = "[${var.environment}] Mysql Aborted connects {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.mysql_aborted_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_aborted_time_aggregator}(${var.mysql_aborted_timeframe}): (
|
||||
avg:mysql.net.aborted_connects${module.filter-tags.query_alert} by {server} /
|
||||
avg:mysql.performance.threads_connected${module.filter-tags.query_alert} by {server}
|
||||
) * 100 > ${var.mysql_aborted_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
warning = "${var.mysql_aborted_threshold_warning}"
|
||||
critical = "${var.mysql_aborted_threshold_critical}"
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_aborted_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_aborted_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_slow" {
|
||||
name = "[${var.environment}] Mysql Slow queries {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = "${coalesce(var.mysql_slow_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_slow_time_aggregator}(${var.mysql_slow_timeframe}): (
|
||||
avg:mysql.performance.slow_queries${module.filter-tags.query_alert} by {server} /
|
||||
avg:mysql.performance.queries${module.filter-tags.query_alert} by {server}
|
||||
) * 100 > ${var.mysql_slow_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
warning = "${var.mysql_slow_threshold_warning}"
|
||||
critical = "${var.mysql_slow_threshold_critical}"
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_slow_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_slow_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_pool_efficiency" {
|
||||
name = "[${var.environment}] Mysql Innodb buffer pool efficiency {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||
message = "${coalesce(var.mysql_pool_efficiency_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_pool_efficiency_time_aggregator}(${var.mysql_pool_efficiency_timeframe}): (
|
||||
avg:mysql.innodb.buffer_pool_reads${module.filter-tags.query_alert} by {server} /
|
||||
avg:mysql.innodb.buffer_pool_read_requests${module.filter-tags.query_alert} by {server}
|
||||
) * 100 > ${var.mysql_pool_efficiency_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
warning = "${var.mysql_pool_efficiency_threshold_warning}"
|
||||
critical = "${var.mysql_pool_efficiency_threshold_critical}"
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_pool_efficiency_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_efficiency_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_pool_utilization" {
|
||||
name = "[${var.environment}] Mysql Innodb buffer pool utilization {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}"
|
||||
message = "${coalesce(var.mysql_pool_utilization_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_pool_utilization_time_aggregator}(${var.mysql_pool_utilization_timeframe}):
|
||||
( avg:mysql.innodb.buffer_pool_total${module.filter-tags.query_alert} by {server} -
|
||||
avg:mysql.innodb.buffer_pool_free${module.filter-tags.query_alert} by {server} ) /
|
||||
avg:mysql.innodb.buffer_pool_total${module.filter-tags.query_alert} by {server}
|
||||
* 100 > ${var.mysql_pool_utilization_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
warning = "${var.mysql_pool_utilization_threshold_warning}"
|
||||
critical = "${var.mysql_pool_utilization_threshold_critical}"
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_pool_utilization_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_pool_utilization_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_threads_anomaly" {
|
||||
name = "[${var.environment}] Mysql threads changed abnormally"
|
||||
message = "${coalesce(var.mysql_threads_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_threads_time_aggregator}(${var.mysql_threads_timeframe}):
|
||||
anomalies(
|
||||
avg:mysql.performance.threads_running${module.filter-tags.query_alert} by {server},
|
||||
'${var.mysql_threads_detection_algorithm}',
|
||||
${var.mysql_threads_deviations},
|
||||
direction='${var.mysql_threads_direction}',
|
||||
alert_window='${var.mysql_threads_alert_window}',
|
||||
interval=${var.mysql_threads_interval},
|
||||
count_default_zero='${var.mysql_threads_count_default_zero}'
|
||||
${var.mysql_threads_seasonality == "agile" ? format(",seasonality='%s'", var.mysql_queries_seasonality): ""}
|
||||
)
|
||||
>= ${var.mysql_threads_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.mysql_threads_threshold_critical}"
|
||||
critical_recovery = 0
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_threads_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_threads_extra_tags}"]
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "mysql_queries_anomaly" {
|
||||
name = "[${var.environment}] Mysql queries changed abnormally"
|
||||
message = "${coalesce(var.mysql_queries_message, var.message)}"
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOF
|
||||
${var.mysql_queries_time_aggregator}(${var.mysql_queries_timeframe}):
|
||||
anomalies(
|
||||
avg:mysql.performance.queries${module.filter-tags.query_alert} by {server},
|
||||
'${var.mysql_queries_detection_algorithm}',
|
||||
${var.mysql_queries_deviations},
|
||||
direction='${var.mysql_queries_direction}',
|
||||
alert_window='${var.mysql_queries_alert_window}',
|
||||
interval=${var.mysql_queries_interval},
|
||||
count_default_zero='${var.mysql_queries_count_default_zero}'
|
||||
${var.mysql_queries_detection_algorithm == "agile" ? format(",seasonality='%s'", var.mysql_queries_seasonality): ""}
|
||||
)
|
||||
>= ${var.mysql_queries_threshold_critical}
|
||||
EOF
|
||||
|
||||
evaluation_delay = "${var.evaluation_delay}"
|
||||
new_host_delay = "${var.new_host_delay}"
|
||||
|
||||
thresholds {
|
||||
critical = "${var.mysql_queries_threshold_critical}"
|
||||
critical_recovery = 0
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
renotify_interval = 0
|
||||
require_full_window = true
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
silenced = "${var.mysql_queries_silenced}"
|
||||
|
||||
tags = ["env:${var.environment}", "type:database", "provider:mysql", "resource:mysql", "team:claranet", "created-by:terraform", "${var.mysql_queries_extra_tags}"]
|
||||
}
|
||||
39
database/mysql/outputs.tf
Normal file
39
database/mysql/outputs.tf
Normal file
@ -0,0 +1,39 @@
|
||||
output "mysql_availability_id" {
|
||||
description = "id for monitor mysql_availability"
|
||||
value = "${datadog_monitor.mysql_availability.id}"
|
||||
}
|
||||
|
||||
output "mysql_connection_id" {
|
||||
description = "id for monitor mysql_connection"
|
||||
value = "${datadog_monitor.mysql_connection.id}"
|
||||
}
|
||||
|
||||
output "mysql_aborted_id" {
|
||||
description = "id for monitor mysql_aborted"
|
||||
value = "${datadog_monitor.mysql_aborted.id}"
|
||||
}
|
||||
|
||||
output "mysql_slow_id" {
|
||||
description = "id for monitor mysql_slow"
|
||||
value = "${datadog_monitor.mysql_slow.id}"
|
||||
}
|
||||
|
||||
output "mysql_pool_efficiency_id" {
|
||||
description = "id for monitor mysql_pool_efficiency"
|
||||
value = "${datadog_monitor.mysql_pool_efficiency.id}"
|
||||
}
|
||||
|
||||
output "mysql_pool_utilization_id" {
|
||||
description = "id for monitor mysql_pool_utilization"
|
||||
value = "${datadog_monitor.mysql_pool_utilization.id}"
|
||||
}
|
||||
|
||||
output "mysql_threads_anomaly_id" {
|
||||
description = "id for monitor mysql_threads_anomaly"
|
||||
value = "${datadog_monitor.mysql_threads_anomaly.id}"
|
||||
}
|
||||
|
||||
output "mysql_queries_anomaly_id" {
|
||||
description = "id for monitor mysql_queries_anomaly"
|
||||
value = "${datadog_monitor.mysql_queries_anomaly.id}"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user