diff --git a/README.md b/README.md index 44a6e0b..b62e5e7 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ module "datadog-monitors-system-generic" { - [redis](https://github.com/claranet/terraform-datadog-monitors/tree/master/database/redis/) - [solr](https://github.com/claranet/terraform-datadog-monitors/tree/master/database/solr/) - [sqlserver](https://github.com/claranet/terraform-datadog-monitors/tree/master/database/sqlserver/) + - [zookeeper](https://github.com/claranet/terraform-datadog-monitors/tree/master/database/zookeeper/) - [middleware](https://github.com/claranet/terraform-datadog-monitors/tree/master/middleware/) - [apache](https://github.com/claranet/terraform-datadog-monitors/tree/master/middleware/apache/) - [kong](https://github.com/claranet/terraform-datadog-monitors/tree/master/middleware/kong/) diff --git a/database/zookeeper/README.md b/database/zookeeper/README.md new file mode 100644 index 0000000..5db9669 --- /dev/null +++ b/database/zookeeper/README.md @@ -0,0 +1,62 @@ +# DATABASE ZOOKEEPER DataDog monitors + +## How to use this module + +```hcl +module "datadog-monitors-database-zookeeper" { + source = "claranet/monitors/datadog//database/zookeeper" + version = "{revision}" + + environment = var.environment + message = module.datadog-message-alerting.alerting-message +} + +``` + +## Purpose + +Creates DataDog monitors with the following checks: + +- Zookeeper latency +- Zookeeper service does not respond + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:-----:| +| environment | Architecture environment | `string` | n/a | yes | +| evaluation\_delay | Delay in seconds for the metric evaluation | `number` | `15` | no | +| filter\_tags\_custom | Tags used for custom filtering when filter\_tags\_use\_defaults is false | `string` | `"*"` | no | +| filter\_tags\_custom\_excluded | Tags excluded 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 a monitor is triggered | `any` | n/a | yes | +| new\_host\_delay | Delay in seconds before begin to monitor new host | `number` | `300` | no | +| not\_responding\_group\_by | List of tags to use to group data | `list(string)` |
[| no | +| not\_responding\_no\_data\_timeframe | Zookeeper monitor no\_data\_timeframe | `number` | `10` | no | +| not\_responding\_notify\_no\_data | Send notification if not\_responding monitor does not retrieve data | `bool` | `true` | no | +| not\_responding\_threshold\_warning | Zookeeper not responding limit (warning threshold) | `number` | `3` | no | +| prefix\_slug | Prefix string to prepend between brackets on every monitors names | `string` | `""` | no | +| zookeeper\_latency\_availability\_extra\_tags | Extra tags for zookeeper read latency monitor | `list(string)` | `[]` | no | +| zookeeper\_latency\_enabled | Flag to enable Zookeeper read latency monitor | `string` | `"true"` | no | +| zookeeper\_latency\_group\_by | Tags to use to group datas | `list(string)` |
"host",
"server"
]
[| no | +| zookeeper\_latency\_status\_message | Custom message for Zookeeper read latency monitor | `string` | `""` | no | +| zookeeper\_latency\_threshold\_critical | Maximum critical acceptable ms of zookeeper latency monitor | `number` | `300000` | no | +| zookeeper\_latency\_threshold\_warning | Maximum warning acceptable ms of zookeeper latency monitor | `number` | `250000` | no | +| zookeeper\_latency\_time\_aggregator | Monitor time aggregator for Zookeeper read latency monitor [available values: min, max or avg] | `string` | `"avg"` | no | +| zookeeper\_latency\_timeframe | Monitor timeframe for Zookeeper read latency monitor [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | `string` | `"last_15m"` | no | +| zookeeper\_not\_responding\_enabled | Flag to enable Zookeeper does not respond monitor | `string` | `"true"` | no | +| zookeeper\_not\_responding\_extra\_tags | Extra tags for Zookeeper does not respond monitor | `list(string)` | `[]` | no | +| zookeeper\_not\_responding\_message | Custom message for Zookeeper does not respond monitor | `string` | `""` | no | +| zookeeper\_not\_responding\_time\_aggregator | Time aggregator for the Zookeeper does not respond monitor | `string` | `"avg"` | no | +| zookeeper\_not\_responding\_timeframe | Timeframe for the does not respond monitor | `string` | `"last_5m"` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| datadog\_monitor\_zookeeper\_latency\_id | id for monitor datadog\_monitor\_zookeeper\_latency | +| not\_responding\_id | id for monitor not\_responding | + +## Related documentation + +DataDog documentation: [https://docs.datadoghq.com/integrations/zk/](https://docs.datadoghq.com/integrations/zk/) diff --git a/database/zookeeper/inputs.tf b/database/zookeeper/inputs.tf new file mode 100644 index 0000000..3874747 --- /dev/null +++ b/database/zookeeper/inputs.tf @@ -0,0 +1,147 @@ +# +# Datadog global variables +# +variable "environment" { + description = "Architecture environment" + type = string +} + +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 = "*" +} + +variable "filter_tags_custom_excluded" { + description = "Tags excluded for custom filtering when filter_tags_use_defaults is false" + default = "" +} + +variable "message" { + description = "Message sent when a monitor is triggered" +} + +variable "evaluation_delay" { + description = "Delay in seconds for the metric evaluation" + default = 15 +} + +variable "new_host_delay" { + description = "Delay in seconds before begin to monitor new host" + default = 300 +} + +variable "prefix_slug" { + description = "Prefix string to prepend between brackets on every monitors names" + default = "" +} + +# +# Service Check +# +variable "not_responding_notify_no_data" { + default = true + type = bool + description = "Send notification if not_responding monitor does not retrieve data" +} +variable "not_responding_no_data_timeframe" { + default = 10 + description = "Zookeeper monitor no_data_timeframe" + type = number +} + +variable "not_responding_group_by" { + default = ["host", "server"] + type = list(string) + description = "List of tags to use to group data" +} + +variable "zookeeper_not_responding_enabled" { + description = "Flag to enable Zookeeper does not respond monitor" + type = string + default = "true" +} + +variable "zookeeper_not_responding_message" { + description = "Custom message for Zookeeper does not respond monitor" + type = string + default = "" +} + +variable "zookeeper_not_responding_time_aggregator" { + description = "Time aggregator for the Zookeeper does not respond monitor" + type = string + default = "avg" +} + +variable "zookeeper_not_responding_timeframe" { + description = "Timeframe for the does not respond monitor" + type = string + default = "last_5m" +} + +variable "zookeeper_not_responding_extra_tags" { + description = "Extra tags for Zookeeper does not respond monitor" + type = list(string) + default = [] +} + +variable "not_responding_threshold_warning" { + default = 3 + type = number + description = "Zookeeper not responding limit (warning threshold)" +} + +# +# Check read latency monitor +# +variable "zookeeper_latency_enabled" { + description = "Flag to enable Zookeeper read latency monitor" + type = string + default = "true" +} + +variable "zookeeper_latency_group_by" { + description = "Tags to use to group datas" + type = list(string) + default = ["host"] +} + +variable "zookeeper_latency_status_message" { + description = "Custom message for Zookeeper read latency monitor" + type = string + default = "" +} + +variable "zookeeper_latency_time_aggregator" { + description = "Monitor time aggregator for Zookeeper read latency monitor [available values: min, max or avg]" + type = string + default = "avg" +} + +variable "zookeeper_latency_timeframe" { + description = "Monitor timeframe for Zookeeper read latency 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 "zookeeper_latency_threshold_critical" { + description = "Maximum critical acceptable ms of zookeeper latency monitor" + default = 300000 +} + +variable "zookeeper_latency_threshold_warning" { + description = "Maximum warning acceptable ms of zookeeper latency monitor" + default = 250000 +} + +variable "zookeeper_latency_availability_extra_tags" { + description = "Extra tags for zookeeper read latency monitor" + type = list(string) + default = [] +} + diff --git a/database/zookeeper/modules.tf b/database/zookeeper/modules.tf new file mode 100644 index 0000000..f0cf5b4 --- /dev/null +++ b/database/zookeeper/modules.tf @@ -0,0 +1,10 @@ +module "filter-tags" { + source = "../../common/filter-tags" + + environment = var.environment + resource = "zookeeper" + filter_tags_use_defaults = var.filter_tags_use_defaults + filter_tags_custom = var.filter_tags_custom + filter_tags_custom_excluded = var.filter_tags_custom_excluded +} + diff --git a/database/zookeeper/monitors-zookeeper.tf b/database/zookeeper/monitors-zookeeper.tf new file mode 100644 index 0000000..884bb6a --- /dev/null +++ b/database/zookeeper/monitors-zookeeper.tf @@ -0,0 +1,65 @@ +resource "datadog_monitor" "not_responding" { + count = var.zookeeper_not_responding_enabled ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Zookeeper service does not respond {{#is_alert}}{{{comparator}}} {{threshold}} ({{value}}){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}} ({{value}}){{/is_warning}}" + message = coalesce(var.zookeeper_not_responding_message, var.message) + type = "service check" + + query = <
"host"
]