MON-286 Unreachable isolated to ease the excluding in non auto muted systems like GCP
This commit is contained in:
parent
61843c980f
commit
3fe5c76730
@ -116,3 +116,4 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
|||||||
- [php-fpm](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/php-fpm/)
|
- [php-fpm](https://bitbucket.org/morea/terraform.feature.datadog/src/master/middleware/php-fpm/)
|
||||||
- [system](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/)
|
- [system](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/)
|
||||||
- [generic](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/generic/)
|
- [generic](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/generic/)
|
||||||
|
- [unreachable](https://bitbucket.org/morea/terraform.feature.datadog/src/master/system/unreachable/)
|
||||||
|
|||||||
@ -22,7 +22,6 @@ Creates DataDog monitors with the following checks:
|
|||||||
- Free disk inodes
|
- Free disk inodes
|
||||||
- Free disk space
|
- Free disk space
|
||||||
- Free memory
|
- Free memory
|
||||||
- Host unreachable
|
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
|
|
||||||
@ -88,11 +87,6 @@ Creates DataDog monitors with the following checks:
|
|||||||
| free_memory_timeframe | Monitor timeframe for Free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
| free_memory_timeframe | Monitor timeframe for Free memory [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no |
|
||||||
| message | Message sent when an alert is triggered | string | - | 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 |
|
||||||
| unreachable_enabled | Flag to enable Host unreachable monitor | string | `true` | no |
|
|
||||||
| unreachable_extra_tags | Extra tags for Host unreachable monitor | list | `<list>` | no |
|
|
||||||
| unreachable_message | Custom message for Host unreachable monitor | string | `` | no |
|
|
||||||
| unreachable_no_data_timeframe | Timeframe for Host unreachable monitor to alert on no data | string | `20` | no |
|
|
||||||
| unreachable_silenced | Groups to mute for Host unreachable monitor | map | `<map>` | no |
|
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
@ -103,7 +97,6 @@ Creates DataDog monitors with the following checks:
|
|||||||
| datadog_free_disk_space_inodes_too_low_id | id for monitor datadog_free_disk_space_inodes_too_low |
|
| datadog_free_disk_space_inodes_too_low_id | id for monitor datadog_free_disk_space_inodes_too_low |
|
||||||
| datadog_free_disk_space_too_low_id | id for monitor datadog_free_disk_space_too_low |
|
| datadog_free_disk_space_too_low_id | id for monitor datadog_free_disk_space_too_low |
|
||||||
| datadog_free_memory_id | id for monitor datadog_free_memory |
|
| datadog_free_memory_id | id for monitor datadog_free_memory |
|
||||||
| datadog_host_unreachable_id | id for monitor datadog_host_unreachable |
|
|
||||||
| datadog_load_too_high_id | id for monitor datadog_load_too_high |
|
| datadog_load_too_high_id | id for monitor datadog_load_too_high |
|
||||||
|
|
||||||
## Related documentation
|
## Related documentation
|
||||||
|
|||||||
@ -31,36 +31,6 @@ variable "filter_tags_custom" {
|
|||||||
|
|
||||||
# System generic specific
|
# System generic specific
|
||||||
|
|
||||||
variable "unreachable_silenced" {
|
|
||||||
description = "Groups to mute for Host unreachable monitor"
|
|
||||||
type = "map"
|
|
||||||
default = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "unreachable_enabled" {
|
|
||||||
description = "Flag to enable Host unreachable monitor"
|
|
||||||
type = "string"
|
|
||||||
default = "true"
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "unreachable_extra_tags" {
|
|
||||||
description = "Extra tags for Host unreachable monitor"
|
|
||||||
type = "list"
|
|
||||||
default = []
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "unreachable_message" {
|
|
||||||
description = "Custom message for Host unreachable monitor"
|
|
||||||
type = "string"
|
|
||||||
default = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "unreachable_no_data_timeframe" {
|
|
||||||
description = "Timeframe for Host unreachable monitor to alert on no data"
|
|
||||||
type = "string"
|
|
||||||
default = 20
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "cpu_high_silenced" {
|
variable "cpu_high_silenced" {
|
||||||
description = "Groups to mute for CPU high monitor"
|
description = "Groups to mute for CPU high monitor"
|
||||||
type = "map"
|
type = "map"
|
||||||
|
|||||||
@ -1,32 +1,3 @@
|
|||||||
resource "datadog_monitor" "datadog_host_unreachable" {
|
|
||||||
count = "${var.unreachable_enabled ? 1 : 0}"
|
|
||||||
name = "[${var.environment}] Host unreachable"
|
|
||||||
message = "${coalesce(var.unreachable_message, var.message)}"
|
|
||||||
|
|
||||||
query = "\"datadog.agent.up\".over${module.filter-tags.service_check}.last(6).count_by_status()"
|
|
||||||
|
|
||||||
type = "service check"
|
|
||||||
|
|
||||||
thresholds {
|
|
||||||
ok = 1
|
|
||||||
warning = 1
|
|
||||||
critical = 5
|
|
||||||
}
|
|
||||||
|
|
||||||
notify_no_data = true
|
|
||||||
no_data_timeframe = "${var.unreachable_no_data_timeframe}"
|
|
||||||
new_host_delay = "${var.new_host_delay}"
|
|
||||||
notify_audit = false
|
|
||||||
timeout_h = 0
|
|
||||||
include_tags = true
|
|
||||||
locked = false
|
|
||||||
require_full_window = true
|
|
||||||
|
|
||||||
silenced = "${var.unreachable_silenced}"
|
|
||||||
|
|
||||||
tags = ["env:${var.environment}", "type:system", "provider:host", "resource:generic", "team:claranet", "created-by:terraform", "${var.unreachable_extra_tags}"]
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "datadog_monitor" "datadog_cpu_too_high" {
|
resource "datadog_monitor" "datadog_cpu_too_high" {
|
||||||
count = "${var.cpu_high_enabled ? 1 : 0}"
|
count = "${var.cpu_high_enabled ? 1 : 0}"
|
||||||
name = "[${var.environment}] CPU usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
name = "[${var.environment}] CPU usage {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||||
|
|||||||
@ -1,8 +1,3 @@
|
|||||||
output "datadog_host_unreachable_id" {
|
|
||||||
description = "id for monitor datadog_host_unreachable"
|
|
||||||
value = "${datadog_monitor.datadog_host_unreachable.*.id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "datadog_cpu_too_high_id" {
|
output "datadog_cpu_too_high_id" {
|
||||||
description = "id for monitor datadog_cpu_too_high"
|
description = "id for monitor datadog_cpu_too_high"
|
||||||
value = "${datadog_monitor.datadog_cpu_too_high.*.id}"
|
value = "${datadog_monitor.datadog_cpu_too_high.*.id}"
|
||||||
|
|||||||
44
system/unreachable/README.md
Normal file
44
system/unreachable/README.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# SYSTEM UNREACHABLE DataDog monitors
|
||||||
|
|
||||||
|
## How to use this module
|
||||||
|
|
||||||
|
```
|
||||||
|
module "datadog-monitors-system-unreachable" {
|
||||||
|
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//system/unreachable?ref={revision}"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
message = "${module.datadog-message-alerting.alerting-message}"
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Creates DataDog monitors with the following checks:
|
||||||
|
|
||||||
|
- Host unreachable
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
| Name | Description | Type | Default | Required |
|
||||||
|
|------|-------------|:----:|:-----:|:-----:|
|
||||||
|
| environment | Architecture 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 |
|
||||||
|
| new_host_delay | Delay in seconds before monitor new resource | string | `300` | no |
|
||||||
|
| unreachable_enabled | Flag to enable Host unreachable monitor | string | `true` | no |
|
||||||
|
| unreachable_extra_tags | Extra tags for Host unreachable monitor | list | `<list>` | no |
|
||||||
|
| unreachable_message | Custom message for Host unreachable monitor | string | `` | no |
|
||||||
|
| unreachable_no_data_timeframe | Timeframe for Host unreachable monitor to alert on no data | string | `20` | no |
|
||||||
|
| unreachable_silenced | Groups to mute for Host unreachable monitor | map | `<map>` | no |
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
|
||||||
|
| Name | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| host_unreachable_id | id for monitor host_unreachable |
|
||||||
|
|
||||||
|
## Related documentation
|
||||||
|
|
||||||
62
system/unreachable/inputs.tf
Normal file
62
system/unreachable/inputs.tf
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Global Terraform
|
||||||
|
variable "environment" {
|
||||||
|
description = "Architecture Environment"
|
||||||
|
type = "string"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Global DataDog
|
||||||
|
variable "evaluation_delay" {
|
||||||
|
description = "Delay in seconds for the metric evaluation"
|
||||||
|
default = 15
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Unreachable
|
||||||
|
|
||||||
|
variable "unreachable_silenced" {
|
||||||
|
description = "Groups to mute for Host unreachable monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "unreachable_enabled" {
|
||||||
|
description = "Flag to enable Host unreachable monitor"
|
||||||
|
type = "string"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "unreachable_extra_tags" {
|
||||||
|
description = "Extra tags for Host unreachable monitor"
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "unreachable_message" {
|
||||||
|
description = "Custom message for Host unreachable monitor"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "unreachable_no_data_timeframe" {
|
||||||
|
description = "Timeframe for Host unreachable monitor to alert on no data"
|
||||||
|
type = "string"
|
||||||
|
default = 20
|
||||||
|
}
|
||||||
8
system/unreachable/modules.tf
Normal file
8
system/unreachable/modules.tf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module "filter-tags" {
|
||||||
|
source = "../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
resource = "system"
|
||||||
|
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||||
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
|
}
|
||||||
28
system/unreachable/monitors-unreachable.tf
Normal file
28
system/unreachable/monitors-unreachable.tf
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
resource "datadog_monitor" "host_unreachable" {
|
||||||
|
count = "${var.unreachable_enabled ? 1 : 0}"
|
||||||
|
name = "[${var.environment}] Host unreachable"
|
||||||
|
message = "${coalesce(var.unreachable_message, var.message)}"
|
||||||
|
|
||||||
|
query = "\"datadog.agent.up\".over${module.filter-tags.service_check}.last(6).count_by_status()"
|
||||||
|
|
||||||
|
type = "service check"
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
ok = 1
|
||||||
|
warning = 1
|
||||||
|
critical = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_no_data = true
|
||||||
|
no_data_timeframe = "${var.unreachable_no_data_timeframe}"
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
silenced = "${var.unreachable_silenced}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "type:system", "provider:host", "resource:unreachable", "team:claranet", "created-by:terraform", "${var.unreachable_extra_tags}"]
|
||||||
|
}
|
||||||
4
system/unreachable/outputs.tf
Normal file
4
system/unreachable/outputs.tf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
output "host_unreachable_id" {
|
||||||
|
description = "id for monitor host_unreachable"
|
||||||
|
value = "${datadog_monitor.host_unreachable.*.id}"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user