MON-92 - Update PR by following recommendations
This commit is contained in:
parent
c4841850d8
commit
e383e800d0
@ -1,8 +1,10 @@
|
|||||||
###MongoDB Monitors
|
AWS MongoDB Service DataDog monitors
|
||||||
|
==========================================
|
||||||
|
|
||||||
Link to integration documentation :
|
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** :
|
**Prepare your ReplicaSet** :
|
||||||
|
|
||||||
@ -46,3 +48,35 @@ Metrics are :
|
|||||||
0: The replicaSet is KO
|
0: The replicaSet is KO
|
||||||
|
|
||||||
This monitor will trigger an alert for each ReplicaSet.
|
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 |
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
../../inputs.tf
|
|
||||||
31
databases/mongodb/inputs.tf
Normal file
31
databases/mongodb/inputs.tf
Normal 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
|
||||||
|
}
|
||||||
@ -1,34 +1,35 @@
|
|||||||
module "message" {
|
data "template_file" "filter" {
|
||||||
source = "../../common/alerting-message"
|
template = "$${filter}"
|
||||||
oncall_24x7 = "${var.hno_escalation_group}"
|
|
||||||
oncall_office_hours = "${var.ho_escalation_group}"
|
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" {
|
resource "datadog_monitor" "mongodb_replicaset_state" {
|
||||||
name = "[${var.env}] Replica Set heath for {{ replset_name }}"
|
name = "[${var.environment}] Replica Set heath for {{ replset_name }}"
|
||||||
message = "${module.message.alerting-message}"
|
message = "${var.message}"
|
||||||
|
|
||||||
query = <<EOF
|
query = <<EOF
|
||||||
avg(last_5m): (
|
avg(last_5m): (
|
||||||
avg:mongodb.replset.health{dd_monitoring:enabled,dd_monitoring_mongodb,env:${var.env}} by {replset_name}
|
avg:mongodb.replset.health{${data.template_file.filter.rendered}} by {region,replset_name}
|
||||||
) == ${var.mongo_config["critical"]}
|
) == ${var.replica_status_critical}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
type = "query alert"
|
type = "metric alert"
|
||||||
|
|
||||||
thresholds {
|
thresholds {
|
||||||
ok = "${var.mongo_config["ok"]}"
|
critical = "${var.replica_status_critical}"
|
||||||
critical = "${var.mongo_config["critical"]}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_no_data = true
|
notify_no_data = true
|
||||||
renotify_interval = 15
|
renotify_interval = 0
|
||||||
evaluation_delay = "${var.mongo_config["delay"]}"
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
new_host_delay = "${var.evaluation_delay}"
|
||||||
notify_audit = false
|
notify_audit = false
|
||||||
timeout_h = 0
|
timeout_h = 0
|
||||||
include_tags = true
|
include_tags = true
|
||||||
locked = false
|
require_full_window = false
|
||||||
require_full_window = true
|
|
||||||
|
|
||||||
tags = ["env:${var.env}", "type:mongodb"]
|
tags = ["env:${var.environment}", "resource:mongodb", "team:aws", "provider:aws"]
|
||||||
}
|
}
|
||||||
|
|||||||
18
inputs.tf
18
inputs.tf
@ -60,8 +60,6 @@ variable "rds_cpu_threshold" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable "rds_mem_threshold" {
|
variable "rds_mem_threshold" {
|
||||||
type = "map"
|
|
||||||
|
|
||||||
default = {
|
default = {
|
||||||
warning = 20
|
warning = 20
|
||||||
critical = 10
|
critical = 10
|
||||||
@ -83,8 +81,6 @@ variable "elb_config" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable "elb_5xx_threshold" {
|
variable "elb_5xx_threshold" {
|
||||||
type = "map"
|
|
||||||
|
|
||||||
default = {
|
default = {
|
||||||
warning = 5
|
warning = 5
|
||||||
critical = 10
|
critical = 10
|
||||||
@ -92,8 +88,6 @@ variable "elb_5xx_threshold" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
variable "elb_4xx_threshold" {
|
variable "elb_4xx_threshold" {
|
||||||
type = "map"
|
|
||||||
|
|
||||||
default = {
|
default = {
|
||||||
warning = 5
|
warning = 5
|
||||||
critical = 10
|
critical = 10
|
||||||
@ -138,15 +132,3 @@ variable "php_fpm_busy_threshold" {
|
|||||||
critical = 0.9
|
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user