Merged in MON-92-added-mongodb-rs-health-check (pull request #33)
MON-92 Added MongoDB Monitor Approved-by: Ahmed Fourti <ahmed.fourti@fr.clara.net> Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr> Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
This commit is contained in:
commit
e1e281110b
81
databases/mongodb/README.md
Normal file
81
databases/mongodb/README.md
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
AWS MongoDB Service DataDog monitors
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
Link to integration documentation :
|
||||||
|
|
||||||
|
[https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/)
|
||||||
|
|
||||||
|
|
||||||
|
**Prepare your ReplicaSet** :
|
||||||
|
|
||||||
|
Add a user to your ReplicaSet (on the primary instance)
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
use admin
|
||||||
|
db.auth("admin", "admin-password") ## This is optional is you don't have any admin password
|
||||||
|
db.createUser({"user":"datadog", "pwd": "{{PASSWORD}}", "roles" : [ {role: 'read', db: 'admin' }, {role: 'clusterMonitor', db: 'admin'}, {role: 'read', db: 'local' }]})
|
||||||
|
```
|
||||||
|
|
||||||
|
**Configure your Datadog agent**
|
||||||
|
|
||||||
|
Add this file conf.d/mongo.yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
init_config:
|
||||||
|
|
||||||
|
instances:
|
||||||
|
- server: mongodb://datadog:password@[MONGO_URI]
|
||||||
|
tags:
|
||||||
|
- mytag1
|
||||||
|
- mytag2
|
||||||
|
- server: mongodb://datadog:password@[MONGO_URI]
|
||||||
|
tags:
|
||||||
|
- mytag1
|
||||||
|
- mytag2
|
||||||
|
```
|
||||||
|
|
||||||
|
**Monitor ReplicaSet Health**
|
||||||
|
|
||||||
|
Name: [environment] Replica Set heath for {{ replset_name }}
|
||||||
|
|
||||||
|
This monitor will check the health of your ReplicaSet
|
||||||
|
|
||||||
|
Metrics are :
|
||||||
|
|
||||||
|
1: The replicaSet is OK
|
||||||
|
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 | `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 |
|
||||||
25
databases/mongodb/inputs.tf
Normal file
25
databases/mongodb/inputs.tf
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# 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 "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 = "*"
|
||||||
|
}
|
||||||
31
databases/mongodb/monitors-mongo.tf
Normal file
31
databases/mongodb/monitors-mongo.tf
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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.environment}] Member down in the replica set"
|
||||||
|
message = "${var.message}"
|
||||||
|
|
||||||
|
query = <<EOF
|
||||||
|
avg(last_5m): (
|
||||||
|
avg:mongodb.replset.health{${data.template_file.filter.rendered}} by {region,replset_name}
|
||||||
|
) < 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
notify_no_data = true
|
||||||
|
renotify_interval = 0
|
||||||
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
new_host_delay = "${var.evaluation_delay}"
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "resource:mongodb"]
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user