Merged in MON-185-add-servicebus-monitors (pull request #85)

MON-185 - Azure - ServiceBus monitors

Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr>
Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
Approved-by: Laurent Piroelle <laurent.piroelle@fr.clara.net>
Approved-by: Adrien Broyere <adrien.broyere@fr.clara.net>
This commit is contained in:
Alexandre Gaillet 2018-05-07 16:05:12 +00:00 committed by Quentin Manfroi
commit d3bf631223
9 changed files with 172 additions and 2 deletions

View File

@ -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/)

View File

@ -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,10 @@ 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 | `<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 | `<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 | `<map>` | no |
| sqldatabase_cpu_threshold_critical | CPU usage in percent (critical threshold) | string | `90` | no |

View File

@ -10,7 +10,6 @@ module "datadog-monitors-azure-eventhub" {
message = "${module.datadog-message-alerting.alerting-message}"
environment = "${var.environment}"
subscription_id = "${var.subscription_id}"
}
```

View File

@ -655,6 +655,30 @@ 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 = ""
}
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"

View File

@ -168,6 +168,22 @@ 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}"
status_timeframe = "${var.servicebus_status_timeframe}"
status_timeframe_aggregator = "${var.servicebus_status_aggregator}"
}
module "sqldatabase" {
source = "./sql-database"

View File

@ -0,0 +1,43 @@
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}"
}
```
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 | `<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
---------------------
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)

View File

@ -0,0 +1,49 @@
# 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 = ""
}
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"
}

View File

@ -0,0 +1,34 @@
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 = <<EOF
${var.status_aggregator}(${var.status_timeframe}): (
${var.status_aggregator}:azure.servicebus_namespaces.status{${data.template_file.filter.rendered}} by {resource_group,region,name}
) != 1
EOF
type = "metric alert"
silenced = "${var.status_silenced}"
notify_no_data = true
evaluation_delay = "${var.delay}"
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
new_host_delay = "${var.delay}"
tags = ["env:${var.environment}", "resource:servicebus", "team:azure", "provider:azure"]
}

View File

@ -10,7 +10,6 @@ module "datadog-monitors-azure-redis" {
message = "${module.datadog-message-alerting.alerting-message}"
environment = "${var.environment}"
subscription_id = "${var.subscription_id}"
}
```