MON-418 Add Azure Load Balancer monitor
This commit is contained in:
parent
02f155b8ec
commit
bb7df320d8
@ -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/)
|
- [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/)
|
- [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/)
|
- [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/)
|
- [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/)
|
- [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/)
|
- [redis](https://git.fr.clara.net/claranet/cloudnative/projects/datadog/terraform/monitors/tree/master/cloud/azure/redis/)
|
||||||
|
|||||||
47
cloud/azure/load-balancer/README.md
Normal file
47
cloud/azure/load-balancer/README.md
Normal file
@ -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)
|
||||||
69
cloud/azure/load-balancer/inputs.tf
Normal file
69
cloud/azure/load-balancer/inputs.tf
Normal file
@ -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 = []
|
||||||
|
}
|
||||||
31
cloud/azure/load-balancer/modules.tf
Normal file
31
cloud/azure/load-balancer/modules.tf
Normal file
@ -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}"
|
||||||
|
}
|
||||||
28
cloud/azure/load-balancer/monitors-load-balancer.tf
Normal file
28
cloud/azure/load-balancer/monitors-load-balancer.tf
Normal file
@ -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 = <<EOF
|
||||||
|
${var.status_time_aggregator}(${var.status_timeframe}): (
|
||||||
|
avg:azure.load-balancer.status${module.filter-tags.query_alert} by {resource_group,region,name}
|
||||||
|
) < 1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
silenced = "${var.status_silenced}"
|
||||||
|
|
||||||
|
notify_no_data = true
|
||||||
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = false
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "type:cloud", "provider:azure", "resource:load-balancer", "team:claranet", "created-by:terraform", "${var.status_extra_tags}"]
|
||||||
|
}
|
||||||
4
cloud/azure/load-balancer/outputs.tf
Normal file
4
cloud/azure/load-balancer/outputs.tf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
output "loadbalancer_status_id" {
|
||||||
|
description = "id for monitor loadbalancer_status"
|
||||||
|
value = "${datadog_monitor.loadbalancer_status.*.id}"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user