MON-92 - Update PR by following recommendations

This commit is contained in:
Alexandre Gaillet 2018-02-19 17:24:12 +01:00
parent c4841850d8
commit e383e800d0
4 changed files with 85 additions and 38 deletions

View File

@ -1,8 +1,10 @@
###MongoDB Monitors
AWS MongoDB Service DataDog monitors
==========================================
Link to integration documentation :
``https://docs.datadoghq.com/integrations/mongo/``
[https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/)
**Prepare your ReplicaSet** :
@ -46,3 +48,35 @@ Metrics are :
0: The replicaSet is KO
This monitor will trigger an alert for each ReplicaSet.
How to use this module
----------------------
```
module "datadog-monitors-aws-mongodb" {
source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}"
message = "${module.datadog-message-alerting.alerting-message}"
environment = "${var.environment}"
}
```
Purpose
-------
Creates a DataDog monitors with the following checks :
* Mongodb ReplicaSet status
Inputs
------
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| environment | Architecture Environment | string | - | yes |
| evaluation_delay | Delay in seconds for the metric evaluation | string | `600` | 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 |
| replica_status_critical | The ReplicaSet status is DOWN | string | `0` | no |

View File

@ -1 +0,0 @@
../../inputs.tf

View File

@ -0,0 +1,31 @@
# Global Terraform
variable "environment" {
description = "Architecture Environment"
type = "string"
}
# Global DataDog
variable "evaluation_delay" {
description = "Delay in seconds for the metric evaluation"
default = 600
}
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 = "*"
}
##MongoDB
variable "replica_status_critical" {
description = "The ReplicaSet status is DOWN"
default = 0
}

View File

@ -1,34 +1,35 @@
module "message" {
source = "../../common/alerting-message"
oncall_24x7 = "${var.hno_escalation_group}"
oncall_office_hours = "${var.ho_escalation_group}"
data "template_file" "filter" {
template = "$${filter}"
vars {
filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_monitoring_mongodb:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}"
}
}
resource "datadog_monitor" "Mongodb_ReplicaSet_State" {
name = "[${var.env}] Replica Set heath for {{ replset_name }}"
message = "${module.message.alerting-message}"
resource "datadog_monitor" "mongodb_replicaset_state" {
name = "[${var.environment}] Replica Set heath for {{ replset_name }}"
message = "${var.message}"
query = <<EOF
avg(last_5m): (
avg:mongodb.replset.health{dd_monitoring:enabled,dd_monitoring_mongodb,env:${var.env}} by {replset_name}
) == ${var.mongo_config["critical"]}
avg:mongodb.replset.health{${data.template_file.filter.rendered}} by {region,replset_name}
) == ${var.replica_status_critical}
EOF
type = "query alert"
type = "metric alert"
thresholds {
ok = "${var.mongo_config["ok"]}"
critical = "${var.mongo_config["critical"]}"
critical = "${var.replica_status_critical}"
}
notify_no_data = true
renotify_interval = 15
evaluation_delay = "${var.mongo_config["delay"]}"
renotify_interval = 0
evaluation_delay = "${var.evaluation_delay}"
new_host_delay = "${var.evaluation_delay}"
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = true
require_full_window = false
tags = ["env:${var.env}", "type:mongodb"]
tags = ["env:${var.environment}", "resource:mongodb", "team:aws", "provider:aws"]
}

View File

@ -60,8 +60,6 @@ variable "rds_cpu_threshold" {
}
variable "rds_mem_threshold" {
type = "map"
default = {
warning = 20
critical = 10
@ -83,8 +81,6 @@ variable "elb_config" {
}
variable "elb_5xx_threshold" {
type = "map"
default = {
warning = 5
critical = 10
@ -92,8 +88,6 @@ variable "elb_5xx_threshold" {
}
variable "elb_4xx_threshold" {
type = "map"
default = {
warning = 5
critical = 10
@ -138,15 +132,3 @@ variable "php_fpm_busy_threshold" {
critical = 0.9
}
}
##MongoDB
variable "mongo_config" {
description = "Critical means the ReplicaSet is DOWN and OK means the ReplicaSet is UP"
type = "map"
default = {
delay = 0
critical = 0
ok = 1
}
}