From c4841850d86c84c994f8c8a243fd21d3cada2227 Mon Sep 17 00:00:00 2001 From: Ahmed Fourti Date: Fri, 1 Dec 2017 17:43:40 +0100 Subject: [PATCH] MON-92 Added MongoDB Monitor --- databases/mongodb/README.md | 48 +++++++++++++++++++++++++++++ databases/mongodb/inputs.tf | 1 + databases/mongodb/monitors-mongo.tf | 34 ++++++++++++++++++++ inputs.tf | 19 +++++++++++- 4 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 databases/mongodb/README.md create mode 120000 databases/mongodb/inputs.tf create mode 100644 databases/mongodb/monitors-mongo.tf diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md new file mode 100644 index 0000000..8407e2a --- /dev/null +++ b/databases/mongodb/README.md @@ -0,0 +1,48 @@ +###MongoDB Monitors + +Link to integration documentation : + +``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. diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf new file mode 120000 index 0000000..cdfc6c6 --- /dev/null +++ b/databases/mongodb/inputs.tf @@ -0,0 +1 @@ +../../inputs.tf \ No newline at end of file diff --git a/databases/mongodb/monitors-mongo.tf b/databases/mongodb/monitors-mongo.tf new file mode 100644 index 0000000..7a0fdc9 --- /dev/null +++ b/databases/mongodb/monitors-mongo.tf @@ -0,0 +1,34 @@ +module "message" { + source = "../../common/alerting-message" + oncall_24x7 = "${var.hno_escalation_group}" + oncall_office_hours = "${var.ho_escalation_group}" +} + +resource "datadog_monitor" "Mongodb_ReplicaSet_State" { + name = "[${var.env}] Replica Set heath for {{ replset_name }}" + message = "${module.message.alerting-message}" + + query = <