From 350faf0fcf62bdd0e76ddba1e3fb9c7505e0282b Mon Sep 17 00:00:00 2001 From: Alexandre Gaillet Date: Fri, 20 Apr 2018 14:51:33 +0200 Subject: [PATCH] MON-185 - ServiceBus monitors added --- cloud/azure/servicebus/README.md | 39 +++++++++++++++++++ cloud/azure/servicebus/inputs.tf | 38 ++++++++++++++++++ .../azure/servicebus/monitors-service-bus.tf | 32 +++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 cloud/azure/servicebus/README.md create mode 100644 cloud/azure/servicebus/inputs.tf create mode 100644 cloud/azure/servicebus/monitors-service-bus.tf diff --git a/cloud/azure/servicebus/README.md b/cloud/azure/servicebus/README.md new file mode 100644 index 0000000..610794d --- /dev/null +++ b/cloud/azure/servicebus/README.md @@ -0,0 +1,39 @@ +Service Bus Datadog monitor +=========================== + +How to use this module +---------------------- + +``` +module "datadog-monitors-azure-servicebus" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/servicebus?ref={revision}" + + message = "${module.datadog-message-alerting.alerting-message}" + environment = "${var.environment}" + subscription_id = "${var.subscription_id}" +} +``` + +Purpose +------- +Creates a Datadog monitor with the following checks : + +* Service status check + +Inputs +------ + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| delay | Delay in seconds for the metric evaluation | string | `900` | 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 | +| status_message | Custom message for Service Bus status monitor | string | `` | no | +| status_silenced | Groups to mute for Service Bus status monitor | map | `` | no | + +Related documentation +--------------------- + +Azure metrics documentation : [https://docs.microsoft.com/fr-fr/azure/monitoring-and-diagnostics/monitoring-supported-metrics#microsoftservicebusnamespaces](https://docs.microsoft.com/fr-fr/azure/monitoring-and-diagnostics/monitoring-supported-metrics#microsoftservicebusnamespaces) diff --git a/cloud/azure/servicebus/inputs.tf b/cloud/azure/servicebus/inputs.tf new file mode 100644 index 0000000..3ea3306 --- /dev/null +++ b/cloud/azure/servicebus/inputs.tf @@ -0,0 +1,38 @@ +# Global Terraform +variable "environment" { + description = "Architecture Environment" + type = "string" +} + +# Global DataDog +variable "delay" { + description = "Delay in seconds for the metric evaluation" + default = 900 +} + +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 = "*" +} + +# Azure Service Bus specific variables +variable "status_silenced" { + description = "Groups to mute for Service Bus status monitor" + type = "map" + default = {} +} + +variable "status_message" { + description = "Custom message for Service Bus status monitor" + type = "string" + default = "" +} diff --git a/cloud/azure/servicebus/monitors-service-bus.tf b/cloud/azure/servicebus/monitors-service-bus.tf new file mode 100644 index 0000000..0efba50 --- /dev/null +++ b/cloud/azure/servicebus/monitors-service-bus.tf @@ -0,0 +1,32 @@ +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_azure_servicebus:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + } +} + +resource "datadog_monitor" "servicebus_status" { + name = "[${var.environment}] Service Bus is down" + message = "${coalesce(var.status_message, var.message)}" + + query = <