From 38177e36707bd520b802f3e1337c91a0bc441bd0 Mon Sep 17 00:00:00 2001 From: Christophe GENINET Date: Wed, 16 May 2018 14:57:25 +0200 Subject: [PATCH 1/9] MON-199 Advanced monitors for Mongo --- databases/mongodb/README.md | 131 +++++++++++++++++----------- databases/mongodb/inputs.tf | 78 +++++++++++++++-- databases/mongodb/monitors-mongo.tf | 75 ++++++++++++++-- 3 files changed, 217 insertions(+), 67 deletions(-) diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index fc521cd..8dfb57b 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -1,58 +1,21 @@ 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 ---------------------- +Add a user to MongoDB (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' }]}) +``` + +Add a module in your Terraform project : + ``` module "datadog-monitors-aws-mongodb" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}" @@ -63,22 +26,86 @@ module "datadog-monitors-aws-mongodb" { } ``` +Configure your Datadog agent for kubernetes with this config : + +``` +datadog: + confd: + mongo.yaml: |- + ad_identifiers: + - mongodb + init_config: + instances: + - server: mongodb://datadog:password@%%host%%/admin + tags: + - dd_monitoring:enabled + - dd_mongodb:enabled + - env:prod +``` + + Purpose ------- Creates a DataDog monitors with the following checks : -* Mongodb ReplicaSet status +* MongoDB Primary status +* MongoDB Secondaries status +* MongoDB replication lag + +**Monitor MongoDB Primary** + +Name: [environment] MongoDB Primary + +This monitor will check the health of the Primary node + +This monitor will trigger an alert if there's no primary or if the primary state is wrong. + + +**Monitor MongoDB Secondary** + +Name: [environment] MongoDB Secondary + +This monitor will check the health for secondaries nodes + +This monitor will trigger an alert if a secondary is missing or if there's a wrong state + + +**Monitor MongoDB Replication lag** + +Name: [environment] MongoDB Replication lag + +This monitor will check the replication lag + +This monitor will trigger an alert if the replication high is too high + Inputs ------ | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| -| delay | Delay in seconds for the metric evaluation | string | `15` | no | | environment | Architecture Environment | string | - | yes | | 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 | -| mongodb_replicaset_message | Custom message for Mongodb replicaset monitor | string | `` | no | -| mongodb_replicaset_silenced | Groups to mute for Mongodb replicaset monitor | map | `` | no | -| mongodb_replicaset_timeframe | Monitor timeframe for Mongodb replicaset [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | +| mongodb_primary_message | Message sent when an alert is triggered on primary state | string | - | no | +| mongodb_secondary_message | Message sent when an alert is triggered on secondary state | string | - | no | +| mongodb_replication_message | Message sent when an alert is triggered on replication lag | string | - | no | +| mongodb_lag_warning | Replication lag in seconds to trigger a warn alert | string | 2 | no | +| mongodb_lag_critical | Replication lag in seconds to trigger a critical alert | string | 5 | no | +| mongodb_primary_silenced | Groups to mute for Mongodb primary state monitor | map | `` | no | +| mongodb_secondary_silenced | Groups to mute for Mongodb secondary state monitor | map | `` | no | +| mongodb_replication_silenced | Groups to mute for Mongodb replication lag monitor | map | `` | no | +| mongodb_replication_aggregator | Monitor aggregator for Mongodb state on primary node | string | available values: min, max | no | +| mongodb_replication_aggregator | Monitor aggregator for Mongodb state for secondaries | string | available values: min, max | no | +| mongodb_replication_aggregator | Monitor aggregator for Mongodb replication lag | string | available values: min, max, sum or avg | no | +| mongodb_primary_timeframe | Time frame for MongoDB primary state | string | available values: `last_#m` (1, 5, 10, 15, or 30) | no | +| mongodb_secondary_timeframe | Time frame for MongoDB secondary state | string | available values: `last_#m` (1, 5, 10, 15, or 30) | no | +| mongodb_replication_timeframe | Time frame for MongoDB replication lag | string | available values: `last_#m` (1, 5, 10, 15, or 30) | no | + + +Related documentation +--------------------- + +[https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/) + diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf index 46cf5ee..54ae5a7 100644 --- a/databases/mongodb/inputs.tf +++ b/databases/mongodb/inputs.tf @@ -24,20 +24,84 @@ variable "filter_tags_custom" { default = "*" } -variable "mongodb_replicaset_silenced" { - description = "Groups to mute for Mongodb replicaset monitor" +variable "mongodb_primary_timeframe" { + description = "Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1m" +} + +variable "mongodb_secondary_timeframe" { + description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1m" +} + +variable "mongodb_replication_timeframe" { + description = "Monitor timeframe for MongoDB replication lag [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1m" +} + +variable "mongodb_lag_warning" { + description = "Warn replication lag in s" + default = 2 +} + +variable "mongodb_lag_critical" { + description = "Critical replication lag in s" + default = 5 +} + +variable "mongodb_primary_silenced" { + description = "Groups to mute for Mongodb primary state monitor" type = "map" default = {} } -variable "mongodb_replicaset_message" { - description = "Custom message for Mongodb replicaset monitor" +variable "mongodb_secondary_silenced" { + description = "Groups to mute for Mongodb secondary state monitor" + type = "map" + default = {} +} + +variable "mongodb_replication_silenced" { + description = "Groups to mute for Mongodb replication lag monitor" + type = "map" + default = {} +} + +variable "mongodb_primary_message" { + description = "Custom message for MongoDB primary monitor" type = "string" default = "" } -variable "mongodb_replicaset_timeframe" { - description = "Monitor timeframe for Mongodb replicaset [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" +variable "mongodb_secondary_message" { + description = "Custom message for MongoDB secondary monitor" type = "string" - default = "last_5m" + default = "" +} + +variable "mongodb_replication_message" { + description = "Custom message for MongoDB replication monitor" + type = "string" + default = "" +} + +variable "mongodb_primary_aggregator" { + description = "Monitor aggregator for Mongodb primary state [available values: min, max]" + type = "string" + default = "max" +} + +variable "mongodb_secondary_aggregator" { + description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + type = "string" + default = "max" +} + +variable "mongodb_replication_aggregator" { + description = "Monitor aggregator for Mongodb replication lag [available values: min, max, sum or avg]" + type = "string" + default = "avg" } diff --git a/databases/mongodb/monitors-mongo.tf b/databases/mongodb/monitors-mongo.tf index 5357aeb..ccaaec3 100644 --- a/databases/mongodb/monitors-mongo.tf +++ b/databases/mongodb/monitors-mongo.tf @@ -2,18 +2,17 @@ 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}"}" + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_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 = "${coalesce(var.mongodb_replicaset_message, var.message)}" +resource "datadog_monitor" "mongodb_primary" { + name = "[${var.environment}] MongoDB primary state" + message = "${coalesce(var.mongodb_primary_message, var.message)}" query = <= 2 EOF type = "metric alert" @@ -27,7 +26,67 @@ resource "datadog_monitor" "mongodb_replicaset_state" { include_tags = true require_full_window = true - silenced = "${var.mongodb_replicaset_silenced}" + silenced = "${var.mongodb_primary_silenced}" + + tags = ["env:${var.environment}", "resource:mongodb"] +} + +resource "datadog_monitor" "mongodb_secondary" { + name = "[${var.environment}] MongoDB secondary state" + message = "${coalesce(var.mongodb_secondary_message, var.message)}" + + query = <= 6 + EOF + + thresholds { + critical = 6 + warning = 3 + } + + type = "metric alert" + + notify_no_data = true + renotify_interval = 0 + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + require_full_window = true + + silenced = "${var.mongodb_secondary_silenced}" + + tags = ["env:${var.environment}", "resource:mongodb"] +} + +resource "datadog_monitor" "mongodb_replication" { + name = "[${var.environment}] MongoDB replication lag" + message = "${coalesce(var.mongodb_replication_message, var.message)}" + + query = < ${var.mongodb_lag_critical} + EOF + + thresholds { + critical = "${var.mongodb_lag_critical}" + warning = "${var.mongodb_lag_warning}" + } + + type = "metric alert" + + notify_no_data = false + renotify_interval = 0 + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + require_full_window = true + + silenced = "${var.mongodb_replication_silenced}" tags = ["env:${var.environment}", "resource:mongodb"] } From ac8585e441a8f8de4dccf9a18d239a3ed4b22de0 Mon Sep 17 00:00:00 2001 From: Laurent Piroelle Date: Tue, 26 Jun 2018 15:21:33 +0200 Subject: [PATCH 2/9] MON-199 Change MongoDB secondary monitoring --- databases/mongodb/inputs.tf | 31 ++++++++++++++++++++- databases/mongodb/monitors-mongo.tf | 43 +++++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf index 54ae5a7..5dbc37f 100644 --- a/databases/mongodb/inputs.tf +++ b/databases/mongodb/inputs.tf @@ -24,6 +24,11 @@ variable "filter_tags_custom" { default = "*" } +variable "mongodb_desired_servers_count" { + description = "Number of servers that should be instanciated for this cluster" + default = 3 +} + variable "mongodb_primary_timeframe" { description = "Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" type = "string" @@ -33,7 +38,13 @@ variable "mongodb_primary_timeframe" { variable "mongodb_secondary_timeframe" { description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" type = "string" - default = "last_1m" + default = "last_5m" +} + +variable "mongodb_server_count_timeframe" { + description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_15m" } variable "mongodb_replication_timeframe" { @@ -64,6 +75,12 @@ variable "mongodb_secondary_silenced" { default = {} } +variable "mongodb_server_count_silenced" { + description = "Groups to mute for Mongodb secondary state monitor" + type = "map" + default = {} +} + variable "mongodb_replication_silenced" { description = "Groups to mute for Mongodb replication lag monitor" type = "map" @@ -82,6 +99,12 @@ variable "mongodb_secondary_message" { default = "" } +variable "mongodb_server_count_message" { + description = "Custom message for MongoDB secondary monitor" + type = "string" + default = "" +} + variable "mongodb_replication_message" { description = "Custom message for MongoDB replication monitor" type = "string" @@ -100,6 +123,12 @@ variable "mongodb_secondary_aggregator" { default = "max" } +variable "mongodb_server_count_aggregator" { + description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + type = "string" + default = "max" +} + variable "mongodb_replication_aggregator" { description = "Monitor aggregator for Mongodb replication lag [available values: min, max, sum or avg]" type = "string" diff --git a/databases/mongodb/monitors-mongo.tf b/databases/mongodb/monitors-mongo.tf index ccaaec3..5f54331 100644 --- a/databases/mongodb/monitors-mongo.tf +++ b/databases/mongodb/monitors-mongo.tf @@ -32,22 +32,55 @@ resource "datadog_monitor" "mongodb_primary" { } resource "datadog_monitor" "mongodb_secondary" { - name = "[${var.environment}] MongoDB secondary state" + name = "[${var.environment}] MongoDB secondary missing" message = "${coalesce(var.mongodb_secondary_message, var.message)}" query = <= 6 + ${var.mongodb_desired_servers_count} - + sum:mongodb.replset.health{${data.template_file.filter.rendered}} by {replset_name} + > 1 EOF thresholds { - critical = 6 - warning = 3 + critical = 1 + warning = 0 } type = "metric alert" - notify_no_data = true + notify_no_data = false + renotify_interval = 0 + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + require_full_window = true + + silenced = "${var.mongodb_secondary_silenced}" + + tags = ["env:${var.environment}", "resource:mongodb"] +} + +resource "datadog_monitor" "mongodb_server_count" { + name = "[${var.environment}] MongoDB too much servers or wrong monitoring config" + message = "${coalesce(var.mongodb_server_count_message, var.message)}" + + query = < 99 + EOF + + thresholds { + critical = 99 + warning = "${var.mongodb_desired_servers_count}" + } + + type = "metric alert" + + notify_no_data = false renotify_interval = 0 evaluation_delay = "${var.delay}" new_host_delay = "${var.delay}" From de448bb087079458caa5549fd2e27f882c9d1596 Mon Sep 17 00:00:00 2001 From: Laurent Piroelle Date: Tue, 26 Jun 2018 17:51:10 +0200 Subject: [PATCH 3/9] MON-199 cleanup & minor fix --- databases/mongodb/README.md | 36 +++++++++++++++++++++--------------- databases/mongodb/inputs.tf | 22 +++++++++++----------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index 8dfb57b..8a15dc4 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -10,7 +10,7 @@ Add a user to MongoDB (on the primary instance) : ``` use admin -db.auth("admin", "admin-password") ## This is optional is you don't have any admin password +db.auth("admin", "admin-password") ## This is optional if 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' }]}) ``` @@ -84,24 +84,30 @@ Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| +| delay | Delay in seconds for the metric evaluation | string | `15` | no | | environment | Architecture Environment | string | - | yes | | 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 | -| mongodb_primary_message | Message sent when an alert is triggered on primary state | string | - | no | -| mongodb_secondary_message | Message sent when an alert is triggered on secondary state | string | - | no | -| mongodb_replication_message | Message sent when an alert is triggered on replication lag | string | - | no | -| mongodb_lag_warning | Replication lag in seconds to trigger a warn alert | string | 2 | no | -| mongodb_lag_critical | Replication lag in seconds to trigger a critical alert | string | 5 | no | -| mongodb_primary_silenced | Groups to mute for Mongodb primary state monitor | map | `` | no | -| mongodb_secondary_silenced | Groups to mute for Mongodb secondary state monitor | map | `` | no | -| mongodb_replication_silenced | Groups to mute for Mongodb replication lag monitor | map | `` | no | -| mongodb_replication_aggregator | Monitor aggregator for Mongodb state on primary node | string | available values: min, max | no | -| mongodb_replication_aggregator | Monitor aggregator for Mongodb state for secondaries | string | available values: min, max | no | -| mongodb_replication_aggregator | Monitor aggregator for Mongodb replication lag | string | available values: min, max, sum or avg | no | -| mongodb_primary_timeframe | Time frame for MongoDB primary state | string | available values: `last_#m` (1, 5, 10, 15, or 30) | no | -| mongodb_secondary_timeframe | Time frame for MongoDB secondary state | string | available values: `last_#m` (1, 5, 10, 15, or 30) | no | -| mongodb_replication_timeframe | Time frame for MongoDB replication lag | string | available values: `last_#m` (1, 5, 10, 15, or 30) | no | +| mongodb_desired_servers_count | Number of servers that should be instanciated for this cluster | string | `3` | no | +| mongodb_lag_critical | Critical replication lag in s | string | `5` | no | +| mongodb_lag_warning | Warn replication lag in s | string | `2` | no | +| mongodb_primary_aggregator | Monitor aggregator for MongoDB primary state [available values: min, max] | string | `max` | no | +| mongodb_primary_message | Custom message for MongoDB primary monitor | string | `` | no | +| mongodb_primary_silenced | Groups to mute for MongoDB primary state monitor | map | `` | no | +| mongodb_primary_timeframe | Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_1m` | no | +| mongodb_replication_aggregator | Monitor aggregator for MongoDB replication lag [available values: min, max, sum or avg] | string | `avg` | no | +| mongodb_replication_message | Custom message for MongoDB replication monitor | string | `` | no | +| mongodb_replication_silenced | Groups to mute for MongoDB replication lag monitor | map | `` | no | +| mongodb_replication_timeframe | Monitor timeframe for MongoDB replication lag [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_1m` | no | +| mongodb_secondary_aggregator | Monitor aggregator for MongoDB secondary state [available values: min, max] | string | `max` | no | +| mongodb_secondary_message | Custom message for MongoDB secondary monitor | string | `` | no | +| mongodb_secondary_silenced | Groups to mute for MongoDB secondary state monitor | map | `` | no | +| mongodb_secondary_timeframe | Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | +| mongodb_server_count_aggregator | Monitor aggregator for MongoDB server count [available values: min, max] | string | `min` | no | +| mongodb_server_count_message | Custom message for MongoDB server count | string | `` | no | +| mongodb_server_count_silenced | Groups to mute for MongoDB server count monitor | map | `` | no | +| mongodb_server_count_timeframe | Monitor timeframe for MongoDB wrong server count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | Related documentation diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf index 5dbc37f..3800ae5 100644 --- a/databases/mongodb/inputs.tf +++ b/databases/mongodb/inputs.tf @@ -42,7 +42,7 @@ variable "mongodb_secondary_timeframe" { } variable "mongodb_server_count_timeframe" { - description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + description = "Monitor timeframe for MongoDB wrong server count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" type = "string" default = "last_15m" } @@ -64,25 +64,25 @@ variable "mongodb_lag_critical" { } variable "mongodb_primary_silenced" { - description = "Groups to mute for Mongodb primary state monitor" + description = "Groups to mute for MongoDB primary state monitor" type = "map" default = {} } variable "mongodb_secondary_silenced" { - description = "Groups to mute for Mongodb secondary state monitor" + description = "Groups to mute for MongoDB secondary state monitor" type = "map" default = {} } variable "mongodb_server_count_silenced" { - description = "Groups to mute for Mongodb secondary state monitor" + description = "Groups to mute for MongoDB server count monitor" type = "map" default = {} } variable "mongodb_replication_silenced" { - description = "Groups to mute for Mongodb replication lag monitor" + description = "Groups to mute for MongoDB replication lag monitor" type = "map" default = {} } @@ -100,7 +100,7 @@ variable "mongodb_secondary_message" { } variable "mongodb_server_count_message" { - description = "Custom message for MongoDB secondary monitor" + description = "Custom message for MongoDB server count" type = "string" default = "" } @@ -112,25 +112,25 @@ variable "mongodb_replication_message" { } variable "mongodb_primary_aggregator" { - description = "Monitor aggregator for Mongodb primary state [available values: min, max]" + description = "Monitor aggregator for MongoDB primary state [available values: min, max]" type = "string" default = "max" } variable "mongodb_secondary_aggregator" { - description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + description = "Monitor aggregator for MongoDB secondary state [available values: min, max]" type = "string" default = "max" } variable "mongodb_server_count_aggregator" { - description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + description = "Monitor aggregator for MongoDB server count [available values: min, max]" type = "string" - default = "max" + default = "min" } variable "mongodb_replication_aggregator" { - description = "Monitor aggregator for Mongodb replication lag [available values: min, max, sum or avg]" + description = "Monitor aggregator for MongoDB replication lag [available values: min, max, sum or avg]" type = "string" default = "avg" } From 70cd12309b99042b7abbec7309d012edadd8854a Mon Sep 17 00:00:00 2001 From: Christophe GENINET Date: Wed, 16 May 2018 14:57:25 +0200 Subject: [PATCH 4/9] MON-199 Advanced monitors for Mongo --- databases/mongodb/README.md | 157 ++++++++++++++++------------ databases/mongodb/inputs.tf | 76 ++++++++++++-- databases/mongodb/monitors-mongo.tf | 109 +++++++++++++++++-- 3 files changed, 261 insertions(+), 81 deletions(-) diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index 193de0e..2850f35 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -1,24 +1,86 @@ -# DATABASES MONGODB DataDog monitors +AWS MongoDB Service DataDog monitors +========================================== -## How to use this module + + +How to use this module +---------------------- + +Add a user to MongoDB (on the primary instance) : ``` -module "datadog-monitors-databases-mongodb" { +use admin +db.auth("admin", "admin-password") ## This is optional if 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' }]}) +``` + +Add a module in your Terraform project : + +``` +module "datadog-monitors-aws-mongodb" { source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}" - environment = "${var.environment}" message = "${module.datadog-message-alerting.alerting-message}" -} + environment = "${var.environment}" +} ``` -## Purpose +Configure your Datadog agent for kubernetes with this config : -Creates DataDog monitors with the following checks: +``` +datadog: + confd: + mongo.yaml: |- + ad_identifiers: + - mongodb + init_config: + instances: + - server: mongodb://datadog:password@%%host%%/admin + tags: + - dd_monitoring:enabled + - dd_mongodb:enabled + - env:prod +``` -- Member down in the replica set -## Inputs +Purpose +------- + +Creates a DataDog monitors with the following checks : +* MongoDB Primary status +* MongoDB Secondaries status +* MongoDB replication lag + +**Monitor MongoDB Primary** + +Name: [environment] MongoDB Primary + +This monitor will check the health of the Primary node + +This monitor will trigger an alert if there's no primary or if the primary state is wrong. + + +**Monitor MongoDB Secondary** + +Name: [environment] MongoDB Secondary + +This monitor will check the health for secondaries nodes + +This monitor will trigger an alert if a secondary is missing or if there's a wrong state + + +**Monitor MongoDB Replication lag** + +Name: [environment] MongoDB Replication lag + +This monitor will check the replication lag + +This monitor will trigger an alert if the replication high is too high + + +Inputs +------ | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| @@ -27,63 +89,30 @@ Creates DataDog monitors with the following checks: | 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 | -| mongodb_replicaset_message | Custom message for Mongodb replicaset monitor | string | `` | no | -| mongodb_replicaset_silenced | Groups to mute for Mongodb replicaset monitor | map | `` | no | -| mongodb_replicaset_time_aggregator | Monitor aggregator for Mongodb replicaset [available values: min, max or avg] | string | `max` | no | -| mongodb_replicaset_timeframe | Monitor timeframe for Mongodb replicaset [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| mongodb_replicaset_state_id | id for monitor mongodb_replicaset_state | - -## Related documentation - -DataDog documentation: [https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/) - -## Custom settings - -### Prepare your ReplicaSet - -Add a user to your ReplicaSet (on the primary instance) +| mongodb_desired_servers_count | Number of servers that should be instanciated for this cluster | string | `3` | no | +| mongodb_lag_critical | Critical replication lag in s | string | `5` | no | +| mongodb_lag_warning | Warn replication lag in s | string | `2` | no | +| mongodb_primary_aggregator | Monitor aggregator for MongoDB primary state [available values: min, max] | string | `max` | no | +| mongodb_primary_message | Custom message for MongoDB primary monitor | string | `` | no | +| mongodb_primary_silenced | Groups to mute for MongoDB primary state monitor | map | `` | no | +| mongodb_primary_timeframe | Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_1m` | no | +| mongodb_replication_aggregator | Monitor aggregator for MongoDB replication lag [available values: min, max, sum or avg] | string | `avg` | no | +| mongodb_replication_message | Custom message for MongoDB replication monitor | string | `` | no | +| mongodb_replication_silenced | Groups to mute for MongoDB replication lag monitor | map | `` | no | +| mongodb_replication_timeframe | Monitor timeframe for MongoDB replication lag [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_1m` | no | +| mongodb_secondary_aggregator | Monitor aggregator for MongoDB secondary state [available values: min, max] | string | `max` | no | +| mongodb_secondary_message | Custom message for MongoDB secondary monitor | string | `` | no | +| mongodb_secondary_silenced | Groups to mute for MongoDB secondary state monitor | map | `` | no | +| mongodb_secondary_timeframe | Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_5m` | no | +| mongodb_server_count_aggregator | Monitor aggregator for MongoDB server count [available values: min, max] | string | `min` | no | +| mongodb_server_count_message | Custom message for MongoDB server count | string | `` | no | +| mongodb_server_count_silenced | Groups to mute for MongoDB server count monitor | map | `` | no | +| mongodb_server_count_timeframe | Monitor timeframe for MongoDB wrong server count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | -``` -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' }]}) -``` +Related documentation +--------------------- -### Configure your Datadog agent +[https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/) -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 index 0df8a02..54ae5a7 100644 --- a/databases/mongodb/inputs.tf +++ b/databases/mongodb/inputs.tf @@ -24,26 +24,84 @@ variable "filter_tags_custom" { default = "*" } -variable "mongodb_replicaset_silenced" { - description = "Groups to mute for Mongodb replicaset monitor" +variable "mongodb_primary_timeframe" { + description = "Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1m" +} + +variable "mongodb_secondary_timeframe" { + description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1m" +} + +variable "mongodb_replication_timeframe" { + description = "Monitor timeframe for MongoDB replication lag [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_1m" +} + +variable "mongodb_lag_warning" { + description = "Warn replication lag in s" + default = 2 +} + +variable "mongodb_lag_critical" { + description = "Critical replication lag in s" + default = 5 +} + +variable "mongodb_primary_silenced" { + description = "Groups to mute for Mongodb primary state monitor" type = "map" default = {} } -variable "mongodb_replicaset_message" { - description = "Custom message for Mongodb replicaset monitor" +variable "mongodb_secondary_silenced" { + description = "Groups to mute for Mongodb secondary state monitor" + type = "map" + default = {} +} + +variable "mongodb_replication_silenced" { + description = "Groups to mute for Mongodb replication lag monitor" + type = "map" + default = {} +} + +variable "mongodb_primary_message" { + description = "Custom message for MongoDB primary monitor" type = "string" default = "" } -variable "mongodb_replicaset_time_aggregator" { - description = "Monitor aggregator for Mongodb replicaset [available values: min, max or avg]" +variable "mongodb_secondary_message" { + description = "Custom message for MongoDB secondary monitor" + type = "string" + default = "" +} + +variable "mongodb_replication_message" { + description = "Custom message for MongoDB replication monitor" + type = "string" + default = "" +} + +variable "mongodb_primary_aggregator" { + description = "Monitor aggregator for Mongodb primary state [available values: min, max]" type = "string" default = "max" } -variable "mongodb_replicaset_timeframe" { - description = "Monitor timeframe for Mongodb replicaset [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" +variable "mongodb_secondary_aggregator" { + description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" type = "string" - default = "last_5m" + default = "max" +} + +variable "mongodb_replication_aggregator" { + description = "Monitor aggregator for Mongodb replication lag [available values: min, max, sum or avg]" + type = "string" + default = "avg" } diff --git a/databases/mongodb/monitors-mongo.tf b/databases/mongodb/monitors-mongo.tf index aaa2549..998db01 100644 --- a/databases/mongodb/monitors-mongo.tf +++ b/databases/mongodb/monitors-mongo.tf @@ -2,18 +2,17 @@ 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}"}" + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_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 = "${coalesce(var.mongodb_replicaset_message, var.message)}" +resource "datadog_monitor" "mongodb_primary" { + name = "[${var.environment}] MongoDB primary state" + message = "${coalesce(var.mongodb_primary_message, var.message)}" query = <= 2 EOF type = "metric alert" @@ -27,7 +26,101 @@ resource "datadog_monitor" "mongodb_replicaset_state" { include_tags = true require_full_window = true - silenced = "${var.mongodb_replicaset_silenced}" + silenced = "${var.mongodb_primary_silenced}" tags = ["env:${var.environment}", "resource:mongodb"] } + +resource "datadog_monitor" "mongodb_secondary" { + name = "[${var.environment}] MongoDB secondary missing" + message = "${coalesce(var.mongodb_secondary_message, var.message)}" + + query = < 1 + EOF + + thresholds { + critical = 1 + warning = 0 + } + + type = "metric alert" + + notify_no_data = false + renotify_interval = 0 + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + require_full_window = true + + silenced = "${var.mongodb_secondary_silenced}" + + tags = ["env:${var.environment}", "resource:mongodb"] +} + +resource "datadog_monitor" "mongodb_server_count" { + name = "[${var.environment}] MongoDB too much servers or wrong monitoring config" + message = "${coalesce(var.mongodb_server_count_message, var.message)}" + + query = < 99 + EOF + + thresholds { + critical = 99 + warning = "${var.mongodb_desired_servers_count}" + } + + type = "metric alert" + + notify_no_data = false + renotify_interval = 0 + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + require_full_window = true + + silenced = "${var.mongodb_secondary_silenced}" + + tags = ["env:${var.environment}", "resource:mongodb"] +} + +resource "datadog_monitor" "mongodb_replication" { + name = "[${var.environment}] MongoDB replication lag" + message = "${coalesce(var.mongodb_replication_message, var.message)}" + + query = < ${var.mongodb_lag_critical} + EOF + + thresholds { + critical = "${var.mongodb_lag_critical}" + warning = "${var.mongodb_lag_warning}" + } + + type = "metric alert" + + notify_no_data = false + renotify_interval = 0 + evaluation_delay = "${var.delay}" + new_host_delay = "${var.delay}" + notify_audit = false + timeout_h = 0 + include_tags = true + require_full_window = true + + silenced = "${var.mongodb_replication_silenced}" + + tags = ["env:${var.environment}", "resource:mongodb"] +} + From c2963f50c81b03b5110e35ac3f75c425e733bcbb Mon Sep 17 00:00:00 2001 From: Laurent Piroelle Date: Tue, 26 Jun 2018 15:21:33 +0200 Subject: [PATCH 5/9] MON-199 Change MongoDB secondary monitoring --- databases/mongodb/inputs.tf | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf index 54ae5a7..5dbc37f 100644 --- a/databases/mongodb/inputs.tf +++ b/databases/mongodb/inputs.tf @@ -24,6 +24,11 @@ variable "filter_tags_custom" { default = "*" } +variable "mongodb_desired_servers_count" { + description = "Number of servers that should be instanciated for this cluster" + default = 3 +} + variable "mongodb_primary_timeframe" { description = "Monitor timeframe for MongoDB wrong state for primary node [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" type = "string" @@ -33,7 +38,13 @@ variable "mongodb_primary_timeframe" { variable "mongodb_secondary_timeframe" { description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" type = "string" - default = "last_1m" + default = "last_5m" +} + +variable "mongodb_server_count_timeframe" { + description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + type = "string" + default = "last_15m" } variable "mongodb_replication_timeframe" { @@ -64,6 +75,12 @@ variable "mongodb_secondary_silenced" { default = {} } +variable "mongodb_server_count_silenced" { + description = "Groups to mute for Mongodb secondary state monitor" + type = "map" + default = {} +} + variable "mongodb_replication_silenced" { description = "Groups to mute for Mongodb replication lag monitor" type = "map" @@ -82,6 +99,12 @@ variable "mongodb_secondary_message" { default = "" } +variable "mongodb_server_count_message" { + description = "Custom message for MongoDB secondary monitor" + type = "string" + default = "" +} + variable "mongodb_replication_message" { description = "Custom message for MongoDB replication monitor" type = "string" @@ -100,6 +123,12 @@ variable "mongodb_secondary_aggregator" { default = "max" } +variable "mongodb_server_count_aggregator" { + description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + type = "string" + default = "max" +} + variable "mongodb_replication_aggregator" { description = "Monitor aggregator for Mongodb replication lag [available values: min, max, sum or avg]" type = "string" From a3c409c3659268aec800a90a5de2a0ecd845a8d0 Mon Sep 17 00:00:00 2001 From: Laurent Piroelle Date: Tue, 26 Jun 2018 17:51:10 +0200 Subject: [PATCH 6/9] MON-199 cleanup & minor fix --- databases/mongodb/inputs.tf | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf index 5dbc37f..3800ae5 100644 --- a/databases/mongodb/inputs.tf +++ b/databases/mongodb/inputs.tf @@ -42,7 +42,7 @@ variable "mongodb_secondary_timeframe" { } variable "mongodb_server_count_timeframe" { - description = "Monitor timeframe for MongoDB wrong state for secondaries nodes [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + description = "Monitor timeframe for MongoDB wrong server count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" type = "string" default = "last_15m" } @@ -64,25 +64,25 @@ variable "mongodb_lag_critical" { } variable "mongodb_primary_silenced" { - description = "Groups to mute for Mongodb primary state monitor" + description = "Groups to mute for MongoDB primary state monitor" type = "map" default = {} } variable "mongodb_secondary_silenced" { - description = "Groups to mute for Mongodb secondary state monitor" + description = "Groups to mute for MongoDB secondary state monitor" type = "map" default = {} } variable "mongodb_server_count_silenced" { - description = "Groups to mute for Mongodb secondary state monitor" + description = "Groups to mute for MongoDB server count monitor" type = "map" default = {} } variable "mongodb_replication_silenced" { - description = "Groups to mute for Mongodb replication lag monitor" + description = "Groups to mute for MongoDB replication lag monitor" type = "map" default = {} } @@ -100,7 +100,7 @@ variable "mongodb_secondary_message" { } variable "mongodb_server_count_message" { - description = "Custom message for MongoDB secondary monitor" + description = "Custom message for MongoDB server count" type = "string" default = "" } @@ -112,25 +112,25 @@ variable "mongodb_replication_message" { } variable "mongodb_primary_aggregator" { - description = "Monitor aggregator for Mongodb primary state [available values: min, max]" + description = "Monitor aggregator for MongoDB primary state [available values: min, max]" type = "string" default = "max" } variable "mongodb_secondary_aggregator" { - description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + description = "Monitor aggregator for MongoDB secondary state [available values: min, max]" type = "string" default = "max" } variable "mongodb_server_count_aggregator" { - description = "Monitor aggregator for Mongodb secondary state [available values: min, max]" + description = "Monitor aggregator for MongoDB server count [available values: min, max]" type = "string" - default = "max" + default = "min" } variable "mongodb_replication_aggregator" { - description = "Monitor aggregator for Mongodb replication lag [available values: min, max, sum or avg]" + description = "Monitor aggregator for MongoDB replication lag [available values: min, max, sum or avg]" type = "string" default = "avg" } From 28f2fd863759dbb397b6122d7ec47ebfd00fdf13 Mon Sep 17 00:00:00 2001 From: Christophe GENINET Date: Thu, 26 Jul 2018 16:37:17 +0200 Subject: [PATCH 7/9] MON-199 autoupdate --- databases/mongodb/README.md | 91 +++++++---------------------- databases/mongodb/monitors-mongo.tf | 1 - databases/mongodb/outputs.tf | 21 ++++++- 3 files changed, 38 insertions(+), 75 deletions(-) diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index 8a15dc4..545f8f3 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -1,86 +1,27 @@ -AWS MongoDB Service DataDog monitors -========================================== +# MONGODB DataDog monitors - - -How to use this module ----------------------- - -Add a user to MongoDB (on the primary instance) : +## How to use this module ``` -use admin -db.auth("admin", "admin-password") ## This is optional if 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' }]}) -``` +module "datadog-monitors-mongodb" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//mongodb?ref={revision}" -Add a module in your Terraform project : - -``` -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}" - + message = "${module.datadog-message-alerting.alerting-message}" } -``` - -Configure your Datadog agent for kubernetes with this config : ``` -datadog: - confd: - mongo.yaml: |- - ad_identifiers: - - mongodb - init_config: - instances: - - server: mongodb://datadog:password@%%host%%/admin - tags: - - dd_monitoring:enabled - - dd_mongodb:enabled - - env:prod -``` +## Purpose -Purpose -------- +Creates DataDog monitors with the following checks: -Creates a DataDog monitors with the following checks : -* MongoDB Primary status -* MongoDB Secondaries status -* MongoDB replication lag +- MongoDB primary state +- MongoDB secondary missing +- MongoDB too much servers or wrong monitoring config +- MongoDB replication lag -**Monitor MongoDB Primary** - -Name: [environment] MongoDB Primary - -This monitor will check the health of the Primary node - -This monitor will trigger an alert if there's no primary or if the primary state is wrong. - - -**Monitor MongoDB Secondary** - -Name: [environment] MongoDB Secondary - -This monitor will check the health for secondaries nodes - -This monitor will trigger an alert if a secondary is missing or if there's a wrong state - - -**Monitor MongoDB Replication lag** - -Name: [environment] MongoDB Replication lag - -This monitor will check the replication lag - -This monitor will trigger an alert if the replication high is too high - - -Inputs ------- +## Inputs | Name | Description | Type | Default | Required | |------|-------------|:----:|:-----:|:-----:| @@ -109,6 +50,14 @@ Inputs | mongodb_server_count_silenced | Groups to mute for MongoDB server count monitor | map | `` | no | | mongodb_server_count_timeframe | Monitor timeframe for MongoDB wrong server count [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | +## Outputs + +| Name | Description | +|------|-------------| +| mongodb_primary_id | id for monitor mongodb_primary | +| mongodb_replication_id | id for monitor mongodb_replication | +| mongodb_secondary_id | id for monitor mongodb_secondary | +| mongodb_server_count_id | id for monitor mongodb_server_count | Related documentation --------------------- diff --git a/databases/mongodb/monitors-mongo.tf b/databases/mongodb/monitors-mongo.tf index 998db01..5f54331 100644 --- a/databases/mongodb/monitors-mongo.tf +++ b/databases/mongodb/monitors-mongo.tf @@ -123,4 +123,3 @@ resource "datadog_monitor" "mongodb_replication" { tags = ["env:${var.environment}", "resource:mongodb"] } - diff --git a/databases/mongodb/outputs.tf b/databases/mongodb/outputs.tf index 39ac537..8355291 100644 --- a/databases/mongodb/outputs.tf +++ b/databases/mongodb/outputs.tf @@ -1,4 +1,19 @@ -output "mongodb_replicaset_state_id" { - description = "id for monitor mongodb_replicaset_state" - value = "${datadog_monitor.mongodb_replicaset_state.id}" +output "mongodb_primary_id" { + description = "id for monitor mongodb_primary" + value = "${datadog_monitor.mongodb_primary.id}" +} + +output "mongodb_secondary_id" { + description = "id for monitor mongodb_secondary" + value = "${datadog_monitor.mongodb_secondary.id}" +} + +output "mongodb_server_count_id" { + description = "id for monitor mongodb_server_count" + value = "${datadog_monitor.mongodb_server_count.id}" +} + +output "mongodb_replication_id" { + description = "id for monitor mongodb_replication" + value = "${datadog_monitor.mongodb_replication.id}" } From 9dfa0663989f19c45a536bf4b7f91f2c88726714 Mon Sep 17 00:00:00 2001 From: Christophe GENINET Date: Thu, 26 Jul 2018 17:03:43 +0200 Subject: [PATCH 8/9] MON-199 readme --- databases/mongodb/README.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index 545f8f3..a1cf9d8 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -1,10 +1,10 @@ -# MONGODB DataDog monitors +# DATABASES MONGODB DataDog monitors ## How to use this module ``` -module "datadog-monitors-mongodb" { - source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//mongodb?ref={revision}" +module "datadog-monitors-databases-mongodb" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//databases/mongodb?ref={revision}" environment = "${var.environment}" message = "${module.datadog-message-alerting.alerting-message}" @@ -59,8 +59,5 @@ Creates DataDog monitors with the following checks: | mongodb_secondary_id | id for monitor mongodb_secondary | | mongodb_server_count_id | id for monitor mongodb_server_count | -Related documentation ---------------------- - -[https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/) +## Related documentation From 02ab6ae51b563f2de4a4c89e758bd22747baa290 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Thu, 9 Aug 2018 17:25:26 +0200 Subject: [PATCH 9/9] MON-199 add documentation to readme --- databases/mongodb/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index a1cf9d8..cabe5bf 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -61,3 +61,5 @@ Creates DataDog monitors with the following checks: ## Related documentation +DataDog documentation: [https://docs.datadoghq.com/integrations/mongo/](https://docs.datadoghq.com/integrations/mongo/) +MongoDB documentation: [https://docs.mongodb.com/manual/administration/monitoring/](https://docs.mongodb.com/manual/administration/monitoring/)