MON-221 add zookeeper monitors
This commit is contained in:
parent
cecf378d05
commit
02cdaef1fa
@ -219,3 +219,4 @@ module "datadog-monitors-system-generic" {
|
||||
- [system](https://github.com/claranet/terraform-datadog-monitors/tree/master/system/)
|
||||
- [generic](https://github.com/claranet/terraform-datadog-monitors/tree/master/system/generic/)
|
||||
- [unreachable](https://github.com/claranet/terraform-datadog-monitors/tree/master/system/unreachable/)
|
||||
|
||||
|
||||
56
database/zookeeper/README.md
Normal file
56
database/zookeeper/README.md
Normal file
@ -0,0 +1,56 @@
|
||||
# DATABASE ZOOKEEPER DataDog monitors
|
||||
|
||||
## How to use this module
|
||||
|
||||
```
|
||||
module "datadog-monitors-database-zookeeper" {
|
||||
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//database/zookeeper?ref={revision}"
|
||||
|
||||
environment = var.environment
|
||||
message = module.datadog-message-alerting.alerting-message
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
Creates DataDog monitors with the following checks:
|
||||
|
||||
- Zookeeper latency
|
||||
- Zookeeper process is down
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Type | Default | Required |
|
||||
|------|-------------|:----:|:-----:|:-----:|
|
||||
| environment | Architecture environment | string | n/a | 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\_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 | string | n/a | yes |
|
||||
| new\_host\_delay | Delay in seconds before begin to monitor new host | string | `"300"` | 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\_status\_message | Custom message for Zookeeper read latency monitor | string | `""` | no |
|
||||
| zookeeper\_latency\_threshold\_critical | Maximum critical acceptable ms of zookeeper latency monitor | string | `"300000"` | no |
|
||||
| zookeeper\_latency\_threshold\_warning | Maximum warning acceptable ms of zookeeper latency monitor | string | `"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\_process\_enabled | Flag to enable Zookeeper does not respond monitor | string | `"true"` | no |
|
||||
| zookeeper\_process\_extra\_tags | Extra tags for Zookeeper does not respond monitor | list(string) | `[]` | no |
|
||||
| zookeeper\_process\_message | Custom message for Zookeeper does not respond monitor | string | `""` | no |
|
||||
| zookeeper\_process\_time\_aggregator | Time aggregator for the Zookeeper does not respond monitor | string | `"avg"` | no |
|
||||
| zookeeper\_process\_timeframe | Timeframe for the does not respond monitor | string | `"last_10m"` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| datadog\_monitor\_zookeeper\_latency\_id | id for monitor datadog_monitor_zookeeper_latency |
|
||||
| datadog\_zookeeper\_process\_down\_id | id for monitor datadog_zookeeper_process_down |
|
||||
|
||||
## Related documentation
|
||||
* [Integration Datadog & ElasticSearch](https://docs.datadoghq.com/integrations/elastic/)
|
||||
* [How to monitor ElasticSearch with Datadog](https://www.datadoghq.com/blog/monitor-elasticsearch-datadog/)
|
||||
114
database/zookeeper/inputs.tf
Normal file
114
database/zookeeper/inputs.tf
Normal file
@ -0,0 +1,114 @@
|
||||
#
|
||||
# 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 "zookeeper_process_enabled" {
|
||||
description = "Flag to enable Zookeeper does not respond monitor"
|
||||
type = string
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "zookeeper_process_message" {
|
||||
description = "Custom message for Zookeeper does not respond monitor"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "zookeeper_process_time_aggregator" {
|
||||
description = "Time aggregator for the Zookeeper does not respond monitor"
|
||||
type = string
|
||||
default = "avg"
|
||||
}
|
||||
|
||||
variable "zookeeper_process_timeframe" {
|
||||
description = "Timeframe for the does not respond monitor"
|
||||
type = string
|
||||
default = "last_10m"
|
||||
}
|
||||
|
||||
variable "zookeeper_process_extra_tags" {
|
||||
description = "Extra tags for Zookeeper does not respond monitor"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
|
||||
## Check read latency monitor
|
||||
variable "zookeeper_latency_enabled" {
|
||||
description = "Flag to enable Zookeeper read latency monitor"
|
||||
type = string
|
||||
default = "true"
|
||||
}
|
||||
|
||||
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 = []
|
||||
}
|
||||
20
database/zookeeper/modules.tf
Normal file
20
database/zookeeper/modules.tf
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
}
|
||||
|
||||
module "filter-tags-check-process" {
|
||||
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
|
||||
extra_tags = ["dd_process_name:zookeeper"]
|
||||
}
|
||||
58
database/zookeeper/monitors-zookeeper.tf
Normal file
58
database/zookeeper/monitors-zookeeper.tf
Normal file
@ -0,0 +1,58 @@
|
||||
resource "datadog_monitor" "datadog_zookeeper_process_down" {
|
||||
count = var.zookeeper_process_enabled == "true" ? 1 : 0
|
||||
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Zookeeper process is down"
|
||||
message = coalesce(var.zookeeper_process_message, var.message)
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOQ
|
||||
${var.zookeeper_process_time_aggregator}(${var.zookeeper_process_timeframe}):
|
||||
min:system.processes.number${module.filter-tags-check-process.query_alert} by {host} < 1
|
||||
EOQ
|
||||
|
||||
thresholds = {
|
||||
critical = 1
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
evaluation_delay = 15
|
||||
new_host_delay = 300
|
||||
notify_audit = false
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
locked = false
|
||||
require_full_window = true
|
||||
|
||||
tags = concat(["env:${var.environment}", "type:process", "provider:process-check", "resource:custom", "team:claranet", "created-by:terraform"], var.zookeeper_process_extra_tags)
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "datadog_monitor_zookeeper_latency" {
|
||||
count = var.zookeeper_latency_enabled == "true" ? 1 : 0
|
||||
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Zookeeper latency {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = coalesce(var.zookeeper_latency_status_message, var.message)
|
||||
type = "metric alert"
|
||||
|
||||
query = <<EOQ
|
||||
${var.zookeeper_latency_time_aggregator}(${var.zookeeper_latency_timeframe}): (
|
||||
zookeeper.avg_latency${module.filter-tags.query_alert} by {host}) > ${var.zookeeper_latency_threshold_critical}
|
||||
EOQ
|
||||
|
||||
thresholds = {
|
||||
warning = var.zookeeper_latency_threshold_warning
|
||||
critical = var.zookeeper_latency_threshold_critical
|
||||
}
|
||||
|
||||
notify_no_data = false
|
||||
evaluation_delay = 15
|
||||
new_host_delay = 300
|
||||
notify_audit = false
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
locked = false
|
||||
require_full_window = true
|
||||
|
||||
tags = concat(["env:${var.environment}", "type:database", "provider:zookeeper", "resource:zookeeper", "team:claranet", "created-by:terraform"], var.zookeeper_latency_availability_extra_tags)
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = ["silenced"]
|
||||
}
|
||||
}
|
||||
10
database/zookeeper/outputs.tf
Normal file
10
database/zookeeper/outputs.tf
Normal file
@ -0,0 +1,10 @@
|
||||
output "datadog_monitor_zookeeper_latency_id" {
|
||||
description = "id for monitor datadog_monitor_zookeeper_latency"
|
||||
value = datadog_monitor.datadog_monitor_zookeeper_latency.*.id
|
||||
}
|
||||
|
||||
output "datadog_zookeeper_process_down_id" {
|
||||
description = "id for monitor datadog_zookeeper_process_down"
|
||||
value = datadog_monitor.datadog_zookeeper_process_down.*.id
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user