From 350faf0fcf62bdd0e76ddba1e3fb9c7505e0282b Mon Sep 17 00:00:00 2001 From: Alexandre Gaillet Date: Fri, 20 Apr 2018 14:51:33 +0200 Subject: [PATCH 1/3] 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 = < Date: Fri, 20 Apr 2018 15:23:01 +0200 Subject: [PATCH 2/3] MON-185 - Global README updated, monitor query updated --- README.md | 1 + cloud/azure/README.md | 3 +++ cloud/azure/eventhub/README.md | 1 - cloud/azure/inputs.tf | 13 +++++++++++++ cloud/azure/monitors.tf | 14 ++++++++++++++ cloud/azure/servicebus/README.md | 4 +++- cloud/azure/servicebus/monitors-service-bus.tf | 4 ++-- cloud/azure/stream-analytics/README.md | 1 - 8 files changed, 36 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 086e8b6..f5f94a5 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ Here is the repository organization: - [eventhub](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/eventhub/) - [iothubs](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/iothubs/) - [redis](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/redis/) + - [servicebus](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/servicebus/) - [sql-database](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/sql-database/) - [storage](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/storage/) - [stream-analytics](https://bitbucket.org/morea/terraform.feature.datadog/src/master/cloud/azure/stream-analytics/) diff --git a/cloud/azure/README.md b/cloud/azure/README.md index af91db8..d956a3c 100644 --- a/cloud/azure/README.md +++ b/cloud/azure/README.md @@ -21,6 +21,7 @@ Creates a set of Azure DataDog monitors for the following components : * Azure SQL monitors * Azure Redis monitors * Azure Event Hub monitors +* Azure Service Bus monitors * Azure Stream Analytics monitors * Azure Storage monitors * Azure IOT Hub monitors @@ -149,6 +150,8 @@ Inputs | redis_server_load_rate_threshold_warning | Server CPU load rate (warning threshold) | string | `70` | no | | redis_status_message | Custom message for Redis status monitor | string | `` | no | | redis_status_silenced | Groups to mute for Redis status monitor | map | `` | no | +| servicebus_status_message | Custom message for Service Bus status monitor | string | `` | no | +| servicebus_status_silenced | Groups to mute for Service Bus status monitor | map | `` | no | | sqldatabase_cpu_message | Custom message for SQL CPU monitor | string | `` | no | | sqldatabase_cpu_silenced | Groups to mute for SQL CPU monitor | map | `` | no | | sqldatabase_cpu_threshold_critical | CPU usage in percent (critical threshold) | string | `90` | no | diff --git a/cloud/azure/eventhub/README.md b/cloud/azure/eventhub/README.md index 7f2ac9b..bc49bd8 100644 --- a/cloud/azure/eventhub/README.md +++ b/cloud/azure/eventhub/README.md @@ -10,7 +10,6 @@ module "datadog-monitors-azure-eventhub" { message = "${module.datadog-message-alerting.alerting-message}" environment = "${var.environment}" - subscription_id = "${var.subscription_id}" } ``` diff --git a/cloud/azure/inputs.tf b/cloud/azure/inputs.tf index 06f73a2..5eff7c9 100644 --- a/cloud/azure/inputs.tf +++ b/cloud/azure/inputs.tf @@ -655,6 +655,19 @@ variable "redis_server_load_rate_threshold_warning" { default = 70 } +# Azure Service Bus specific variables +variable "servicebus_status_silenced" { + description = "Groups to mute for Service Bus status monitor" + type = "map" + default = {} +} + +variable "servicebus_status_message" { + description = "Custom message for Service Bus status monitor" + type = "string" + default = "" +} + # Azure SQL Database specific variables variable "sqldatabase_cpu_silenced" { description = "Groups to mute for SQL CPU monitor" diff --git a/cloud/azure/monitors.tf b/cloud/azure/monitors.tf index 33686d0..ceeafe1 100644 --- a/cloud/azure/monitors.tf +++ b/cloud/azure/monitors.tf @@ -168,6 +168,20 @@ module "redis" { server_load_rate_threshold_warning = "${var.redis_server_load_rate_threshold_warning}" } +module "servicebus" { + source = "./servicebus" + + environment = "${var.environment}" + message = "${var.message}" + delay = "${var.delay}" + + filter_tags_use_defaults = "${var.filter_tags_use_defaults}" + filter_tags_custom = "${var.filter_tags_custom}" + + status_silenced = "${var.servicebus_status_silenced}" + status_message = "${var.servicebus_status_message}" +} + module "sqldatabase" { source = "./sql-database" diff --git a/cloud/azure/servicebus/README.md b/cloud/azure/servicebus/README.md index 610794d..0de63c3 100644 --- a/cloud/azure/servicebus/README.md +++ b/cloud/azure/servicebus/README.md @@ -10,7 +10,6 @@ module "datadog-monitors-azure-servicebus" { message = "${module.datadog-message-alerting.alerting-message}" environment = "${var.environment}" - subscription_id = "${var.subscription_id}" } ``` @@ -36,4 +35,7 @@ Inputs Related documentation --------------------- +DataDog documentation : [https://docs.datadoghq.com/integrations/azure/](https://docs.datadoghq.com/integrations/azure/) +You must search `servicebus`, there is no integration for now. + 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/monitors-service-bus.tf b/cloud/azure/servicebus/monitors-service-bus.tf index 0efba50..f9bdb8a 100644 --- a/cloud/azure/servicebus/monitors-service-bus.tf +++ b/cloud/azure/servicebus/monitors-service-bus.tf @@ -11,8 +11,8 @@ resource "datadog_monitor" "servicebus_status" { message = "${coalesce(var.status_message, var.message)}" query = < Date: Fri, 27 Apr 2018 11:27:24 +0200 Subject: [PATCH 3/3] MON-185 - Monitor updated with last best practices --- cloud/azure/README.md | 2 ++ cloud/azure/inputs.tf | 11 +++++++++++ cloud/azure/monitors.tf | 6 ++++-- cloud/azure/servicebus/README.md | 2 ++ cloud/azure/servicebus/inputs.tf | 11 +++++++++++ cloud/azure/servicebus/monitors-service-bus.tf | 4 +++- 6 files changed, 33 insertions(+), 3 deletions(-) diff --git a/cloud/azure/README.md b/cloud/azure/README.md index d956a3c..1a02600 100644 --- a/cloud/azure/README.md +++ b/cloud/azure/README.md @@ -152,6 +152,8 @@ Inputs | redis_status_silenced | Groups to mute for Redis status monitor | map | `` | no | | servicebus_status_message | Custom message for Service Bus status monitor | string | `` | no | | servicebus_status_silenced | Groups to mute for Service Bus status monitor | map | `` | no | +| servicebus_status_timeframe | Monitor timeframe for Service Bus status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | +| servicebus_status_aggregator | Monitor timeframe aggregator for Service Bus status [available values: min, max, sum or avg] | string | `min` | no | | sqldatabase_cpu_message | Custom message for SQL CPU monitor | string | `` | no | | sqldatabase_cpu_silenced | Groups to mute for SQL CPU monitor | map | `` | no | | sqldatabase_cpu_threshold_critical | CPU usage in percent (critical threshold) | string | `90` | no | diff --git a/cloud/azure/inputs.tf b/cloud/azure/inputs.tf index 5eff7c9..f7b804f 100644 --- a/cloud/azure/inputs.tf +++ b/cloud/azure/inputs.tf @@ -668,6 +668,17 @@ variable "servicebus_status_message" { default = "" } +variable "servicebus_status_aggregator" { + description = "Monitor aggregator for Service Bus status [available values: min, max, sum or avg]" + type = "string" + default = "min" +} + +variable "servicebus_status_timeframe" { + description = "Monitor timeframe for Service Bus status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + default = "last_15m" +} + # Azure SQL Database specific variables variable "sqldatabase_cpu_silenced" { description = "Groups to mute for SQL CPU monitor" diff --git a/cloud/azure/monitors.tf b/cloud/azure/monitors.tf index ceeafe1..b16988e 100644 --- a/cloud/azure/monitors.tf +++ b/cloud/azure/monitors.tf @@ -178,8 +178,10 @@ module "servicebus" { filter_tags_use_defaults = "${var.filter_tags_use_defaults}" filter_tags_custom = "${var.filter_tags_custom}" - status_silenced = "${var.servicebus_status_silenced}" - status_message = "${var.servicebus_status_message}" + status_silenced = "${var.servicebus_status_silenced}" + status_message = "${var.servicebus_status_message}" + status_timeframe = "${var.servicebus_status_timeframe}" + status_timeframe_aggregator = "${var.servicebus_status_aggregator}" } module "sqldatabase" { diff --git a/cloud/azure/servicebus/README.md b/cloud/azure/servicebus/README.md index 0de63c3..461ee40 100644 --- a/cloud/azure/servicebus/README.md +++ b/cloud/azure/servicebus/README.md @@ -31,6 +31,8 @@ Inputs | 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 | +| status_timeframe | Monitor timeframe for Service Bus status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `last_15m` | no | +| status_aggregator | Monitor aggregator for Service Bus status [available values: min, max, sum or avg] | string | `min` | no | Related documentation --------------------- diff --git a/cloud/azure/servicebus/inputs.tf b/cloud/azure/servicebus/inputs.tf index 3ea3306..6ea0587 100644 --- a/cloud/azure/servicebus/inputs.tf +++ b/cloud/azure/servicebus/inputs.tf @@ -36,3 +36,14 @@ variable "status_message" { type = "string" default = "" } + +variable "status_aggregator" { + description = "Monitor aggregator for Service Bus status [available values: min, max, sum or avg]" + type = "string" + default = "min" +} + +variable "status_timeframe" { + description = "Monitor timeframe for Service Bus status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + default = "last_15m" +} diff --git a/cloud/azure/servicebus/monitors-service-bus.tf b/cloud/azure/servicebus/monitors-service-bus.tf index f9bdb8a..607d99b 100644 --- a/cloud/azure/servicebus/monitors-service-bus.tf +++ b/cloud/azure/servicebus/monitors-service-bus.tf @@ -11,7 +11,9 @@ resource "datadog_monitor" "servicebus_status" { message = "${coalesce(var.status_message, var.message)}" query = <