diff --git a/README.md b/README.md index f1093fe..1641b86 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi - [eventhub](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/eventhub/) - [iothubs](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/iothubs/) - [keyvault](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/keyvault/) + - [load-balancer](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/load-balancer/) - [mysql](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/mysql/) - [postgresql](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/postgresql/) - [redis](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/redis/) diff --git a/cloud/azure/load-balancer/README.md b/cloud/azure/load-balancer/README.md new file mode 100644 index 0000000..4e86602 --- /dev/null +++ b/cloud/azure/load-balancer/README.md @@ -0,0 +1,47 @@ +# CLOUD AZURE LOAD-BALANCER DataDog monitors + +## How to use this module + +``` +module "datadog-monitors-cloud-azure-load-balancer" { + source = "git::ssh://git@git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors.git//cloud/azure/load-balancer?ref={revision}" + + environment = "${var.environment}" + message = "${module.datadog-message-alerting.alerting-message}" +} + +``` + +## Purpose + +Creates DataDog monitors with the following checks: + +- Load Balancer is down + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| environment | Architecture environment | string | n/a | yes | +| evaluation\_delay | Delay in seconds for the metric evaluation | string | `"900"` | no | +| filter\_tags\_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `"*"` | no | +| filter\_tags\_custom\_excluded | Tags excluded 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 a monitor is triggered | string | n/a | yes | +| new\_host\_delay | Delay in seconds before monitor new resource | string | `"300"` | no | +| status\_enabled | Flag to enable Load Balancer status monitor | string | `"true"` | no | +| status\_extra\_tags | Extra tags for Load Balancer status monitor | list | `[]` | no | +| status\_message | Custom message for Load Balancer status monitor | string | `""` | no | +| status\_silenced | Groups to mute for Load Balancer status monitor | map | `{}` | no | +| status\_time\_aggregator | Monitor aggregator for Load Balancer status [available values: min, max or avg] | string | `"max"` | no | +| status\_timeframe | Monitor timeframe for Load Balancer status [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 | +|------|-------------| +| loadbalancer\_status\_id | id for monitor loadbalancer_status | + +## Related documentation + +DataDog documentation: [https://docs.datadoghq.com/integrations/azure/?tab=azurecliv20](https://docs.datadoghq.com/integrations/azure/?tab=azurecliv20) diff --git a/cloud/azure/load-balancer/inputs.tf b/cloud/azure/load-balancer/inputs.tf new file mode 100644 index 0000000..e92e504 --- /dev/null +++ b/cloud/azure/load-balancer/inputs.tf @@ -0,0 +1,69 @@ +variable "environment" { + description = "Architecture environment" + type = "string" +} + +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 = "*" +} + +variable "filter_tags_custom_excluded" { + description = "Tags excluded for custom filtering when filter_tags_use_defaults is false" + default = "" +} + +variable "message" { + description = "Message sent when a monitor is triggered" +} + +variable "evaluation_delay" { + description = "Delay in seconds for the metric evaluation" + default = 900 +} + +variable "new_host_delay" { + description = "Delay in seconds before monitor new resource" + default = 300 +} + +# Azure Load Balancer specific variables +variable "status_enabled" { + description = "Flag to enable Load Balancer status monitor" + type = "string" + default = "true" +} + +variable "status_silenced" { + description = "Groups to mute for Load Balancer status monitor" + type = "map" + default = {} +} + +variable "status_message" { + description = "Custom message for Load Balancer status monitor" + type = "string" + default = "" +} + +variable "status_time_aggregator" { + description = "Monitor aggregator for Load Balancer status [available values: min, max or avg]" + type = "string" + default = "max" +} + +variable "status_timeframe" { + description = "Monitor timeframe for Load Balancer status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]" + default = "last_5m" +} + +variable "status_extra_tags" { + description = "Extra tags for Load Balancer status monitor" + type = "list" + default = [] +} diff --git a/cloud/azure/load-balancer/modules.tf b/cloud/azure/load-balancer/modules.tf new file mode 100644 index 0000000..d89b7cd --- /dev/null +++ b/cloud/azure/load-balancer/modules.tf @@ -0,0 +1,31 @@ +module "filter-tags" { + source = "../../../common/filter-tags" + + environment = "${var.environment}" + resource = "azure_load-balancer" + filter_tags_use_defaults = "${var.filter_tags_use_defaults}" + filter_tags_custom = "${var.filter_tags_custom}" + filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" +} + +module "filter-tags-statuscode" { + source = "../../../common/filter-tags" + + environment = "${var.environment}" + resource = "azure_load-balancer" + filter_tags_use_defaults = "${var.filter_tags_use_defaults}" + filter_tags_custom = "${var.filter_tags_custom},statuscode:%s" + filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" + + extra_tags = ["statuscode:%s"] +} + +module "filter-tags-activity" { + source = "../../../common/filter-tags" + + environment = "${var.environment}" + resource = "azure_load-balancer" + filter_tags_use_defaults = "${var.filter_tags_use_defaults}" + filter_tags_custom = "${var.filter_tags_custom},!activityname:secretlist" + filter_tags_custom_excluded = "${var.filter_tags_custom_excluded}" +} diff --git a/cloud/azure/load-balancer/monitors-load-balancer.tf b/cloud/azure/load-balancer/monitors-load-balancer.tf new file mode 100644 index 0000000..e471bfa --- /dev/null +++ b/cloud/azure/load-balancer/monitors-load-balancer.tf @@ -0,0 +1,28 @@ +resource "datadog_monitor" "loadbalancer_status" { + count = "${var.status_enabled ? 1 : 0}" + + name = "[${var.environment}] Load Balancer is down" + message = "${coalesce(var.status_message, var.message)}" + + query = <