From e383e800d01cb5ce772ced408b126516dae0a3c2 Mon Sep 17 00:00:00 2001 From: Alexandre Gaillet Date: Mon, 19 Feb 2018 17:24:12 +0100 Subject: [PATCH] MON-92 - Update PR by following recommendations --- databases/mongodb/README.md | 38 +++++++++++++++++++++++++++-- databases/mongodb/inputs.tf | 32 +++++++++++++++++++++++- databases/mongodb/monitors-mongo.tf | 35 +++++++++++++------------- inputs.tf | 18 -------------- 4 files changed, 85 insertions(+), 38 deletions(-) mode change 120000 => 100644 databases/mongodb/inputs.tf diff --git a/databases/mongodb/README.md b/databases/mongodb/README.md index 8407e2a..0ee13b3 100644 --- a/databases/mongodb/README.md +++ b/databases/mongodb/README.md @@ -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 | diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf deleted file mode 120000 index cdfc6c6..0000000 --- a/databases/mongodb/inputs.tf +++ /dev/null @@ -1 +0,0 @@ -../../inputs.tf \ No newline at end of file diff --git a/databases/mongodb/inputs.tf b/databases/mongodb/inputs.tf new file mode 100644 index 0000000..e5e1cc6 --- /dev/null +++ b/databases/mongodb/inputs.tf @@ -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 +} diff --git a/databases/mongodb/monitors-mongo.tf b/databases/mongodb/monitors-mongo.tf index 7a0fdc9..86d25cf 100644 --- a/databases/mongodb/monitors-mongo.tf +++ b/databases/mongodb/monitors-mongo.tf @@ -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 = <