Merge branch 'MON-366-azure-application-gateway' into 'master'

MON-366 Add Azure application gateway monitor

See merge request claranet/pt-monitoring/projects/datadog/terraform/monitors!125
This commit is contained in:
Quentin Manfroi 2019-11-12 18:50:25 +01:00
commit 1e8e6daddb
6 changed files with 906 additions and 0 deletions

View File

@ -161,6 +161,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
- [vpn](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/vpn/)
- [azure](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/)
- [apimanagement](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/apimanagement/)
- [app-gateway](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/app-gateway/)
- [app-services](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/app-services/)
- [azure-search](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/azure-search/)
- [cosmosdb](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/azure/cosmosdb/)

View File

@ -0,0 +1,116 @@
# CLOUD AZURE APP-GATEWAY DataDog monitors
## How to use this module
```
module "datadog-monitors-cloud-azure-app-gateway" {
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/azure/app-gateway?ref={revision}"
environment = var.environment
message = module.datadog-message-alerting.alerting-message
}
```
## Purpose
Creates DataDog monitors with the following checks:
- App Gateway backend connect time is too high
- App Gateway backend HTTP 4xx errors rate is too high
- App Gateway backend HTTP 5xx errors rate is too high
- App Gateway backend unhealthy host ratio is too high
- App Gateway failed requests
- App Gateway has no connection
- App Gateway HTTP 4xx errors rate is too high
- App Gateway HTTP 5xx errors rate is too high
- App Gateway is down
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| appgateway\_backend\_connect\_time\_enabled | Flag to enable App Gateway backend_connect_time monitor | string | `"true"` | no |
| appgateway\_backend\_connect\_time\_extra\_tags | Extra tags for App Gateway backend_connect_time monitor | list(string) | `[]` | no |
| appgateway\_backend\_connect\_time\_message | Custom message for App Gateway backend_connect_time monitor | string | `""` | no |
| appgateway\_backend\_connect\_time\_threshold\_critical | Maximum critical backend_connect_time errors in milliseconds | string | `"50"` | no |
| appgateway\_backend\_connect\_time\_threshold\_warning | Warning regarding backend_connect_time errors in milliseconds | string | `"40"` | no |
| appgateway\_backend\_connect\_time\_time\_aggregator | Monitor aggregator for App Gateway backend_connect_time [available values: min, max or avg] | string | `"max"` | no |
| appgateway\_backend\_connect\_time\_timeframe | Monitor timeframe for App Gateway backend_connect_time [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| appgateway\_backend\_http\_4xx\_errors\_enabled | Flag to enable App Gateway http 4xx errors monitor | string | `"true"` | no |
| appgateway\_backend\_http\_4xx\_errors\_extra\_tags | Extra tags for App Gateway http 4xx errors monitor | list(string) | `[]` | no |
| appgateway\_backend\_http\_4xx\_errors\_message | Custom message for App Gateway http 4xx errors monitor | string | `""` | no |
| appgateway\_backend\_http\_4xx\_errors\_threshold\_critical | Minimum critical acceptable percent of 4xx error | string | `"95"` | no |
| appgateway\_backend\_http\_4xx\_errors\_threshold\_warning | Warning regarding acceptable percent of 4xx error | string | `"80"` | no |
| appgateway\_backend\_http\_4xx\_errors\_time\_aggregator | Monitor aggregator for App Gateway http 4xx errors [available values: min, max or avg] | string | `"max"` | no |
| appgateway\_backend\_http\_4xx\_errors\_timeframe | Monitor timeframe for App Gateway http 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| appgateway\_backend\_http\_5xx\_errors\_enabled | Flag to enable App Gateway http 5xx errors monitor | string | `"true"` | no |
| appgateway\_backend\_http\_5xx\_errors\_extra\_tags | Extra tags for App Gateway http 5xx errors monitor | list(string) | `[]` | no |
| appgateway\_backend\_http\_5xx\_errors\_message | Custom message for App Gateway http 5xx errors monitor | string | `""` | no |
| appgateway\_backend\_http\_5xx\_errors\_threshold\_critical | Minimum critical acceptable percent of 5xx error | string | `"95"` | no |
| appgateway\_backend\_http\_5xx\_errors\_threshold\_warning | Warning regarding acceptable percent of 5xx error | string | `"80"` | no |
| appgateway\_backend\_http\_5xx\_errors\_time\_aggregator | Monitor aggregator for App Gateway http 5xx errors [available values: min, max or avg] | string | `"max"` | no |
| appgateway\_backend\_http\_5xx\_errors\_timeframe | Monitor timeframe for App Gateway http 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| appgateway\_failed\_requests\_enabled | Flag to enable App Gateway failed requests monitor | string | `"true"` | no |
| appgateway\_failed\_requests\_extra\_tags | Extra tags for App Gateway failed requests monitor | list(string) | `[]` | no |
| appgateway\_failed\_requests\_message | Custom message for App Gateway failed requests monitor | string | `""` | no |
| appgateway\_failed\_requests\_threshold\_critical | Maximum critical acceptable percent of failed errors | string | `"95"` | no |
| appgateway\_failed\_requests\_threshold\_warning | Warning regarding acceptable percent of failed errors | string | `"80"` | no |
| appgateway\_failed\_requests\_time\_aggregator | Monitor aggregator for App Gateway failed requests [available values: min, max or avg] | string | `"min"` | no |
| appgateway\_failed\_requests\_timeframe | Monitor timeframe for App Gateway failed requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| appgateway\_http\_4xx\_errors\_enabled | Flag to enable App Gateway http 4xx errors monitor | string | `"true"` | no |
| appgateway\_http\_4xx\_errors\_extra\_tags | Extra tags for App Gateway http 4xx errors monitor | list(string) | `[]` | no |
| appgateway\_http\_4xx\_errors\_message | Custom message for App Gateway http 4xx errors monitor | string | `""` | no |
| appgateway\_http\_4xx\_errors\_threshold\_critical | Maximum critical acceptable percent of 4xx error | string | `"95"` | no |
| appgateway\_http\_4xx\_errors\_threshold\_warning | Warning regarding acceptable percent of 4xx error | string | `"80"` | no |
| appgateway\_http\_4xx\_errors\_time\_aggregator | Monitor aggregator for App Gateway http 4xx errors [available values: min, max or avg] | string | `"max"` | no |
| appgateway\_http\_4xx\_errors\_timeframe | Monitor timeframe for App Gateway http 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| appgateway\_http\_5xx\_errors\_enabled | Flag to enable App Gateway http 5xx errors monitor | string | `"true"` | no |
| appgateway\_http\_5xx\_errors\_extra\_tags | Extra tags for App Gateway http 5xx errors monitor | list(string) | `[]` | no |
| appgateway\_http\_5xx\_errors\_message | Custom message for App Gateway http 5xx errors monitor | string | `""` | no |
| appgateway\_http\_5xx\_errors\_threshold\_critical | Maximum critical acceptable percent of 5xx error | string | `"95"` | no |
| appgateway\_http\_5xx\_errors\_threshold\_warning | Warning regarding acceptable percent of 5xx error | string | `"80"` | no |
| appgateway\_http\_5xx\_errors\_time\_aggregator | Monitor aggregator for App Gateway http 5xx errors [available values: min, max or avg] | string | `"max"` | no |
| appgateway\_http\_5xx\_errors\_timeframe | Monitor timeframe for App Gateway http 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| appgateway\_unhealthy\_host\_ratio\_enabled | Flag to enable App Gateway unhealthy host ratio monitor | string | `"true"` | no |
| appgateway\_unhealthy\_host\_ratio\_extra\_tags | Extra tags for App Gateway unhealthy host ratio monitor | list(string) | `[]` | no |
| appgateway\_unhealthy\_host\_ratio\_message | Custom message for App Gateway unhealthy host ratio monitor | string | `""` | no |
| appgateway\_unhealthy\_host\_ratio\_threshold\_critical | Maximum critical acceptable ratio of unhealthy host | string | `"75"` | no |
| appgateway\_unhealthy\_host\_ratio\_threshold\_warning | Warning regarding acceptable ratio of unhealthy host | string | `"50"` | no |
| appgateway\_unhealthy\_host\_ratio\_time\_aggregator | Monitor aggregator for App Gateway unhealthy host ratio [available values: min, max or avg] | string | `"max"` | no |
| appgateway\_unhealthy\_host\_ratio\_timeframe | Monitor timeframe for App Gateway unhealthy host ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| current\_connection\_enabled | Flag to enable App Gateway current connections monitor | string | `"true"` | no |
| current\_connection\_extra\_tags | Extra tags for App Gateway current connections monitor | list(string) | `[]` | no |
| current\_connection\_message | Custom message for App Gateway current connections monitor | string | `""` | no |
| current\_connection\_time\_aggregator | Monitor aggregator for App Gateway current connections [available values: min, max or avg] | string | `"max"` | no |
| current\_connection\_timeframe | Monitor timeframe for App Gateway current connections [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
| 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 |
| prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no |
| status\_enabled | Flag to enable App Gateway status | string | `"true"` | no |
| status\_extra\_tags | Extra tags for App Gateway status | list(string) | `[]` | no |
| status\_message | Custom message for App Gateway status | string | `""` | no |
| status\_time\_aggregator | Monitor aggregator for App Gateway status [available values: min, max or avg] | string | `"max"` | no |
| status\_timeframe | Monitor timeframe for App Gateway 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 |
|------|-------------|
| appgateway\_backend\_connect\_time\_id | id for monitor appgateway_backend_connect_time |
| appgateway\_backend\_http\_4xx\_errors\_id | id for monitor appgateway_backend_http_4xx_errors |
| appgateway\_backend\_http\_5xx\_errors\_id | id for monitor appgateway_backend_http_5xx_errors |
| appgateway\_failed\_requests\_id | id for monitor appgateway_failed_requests |
| appgateway\_healthy\_host\_ratio\_id | id for monitor appgateway_healthy_host_ratio |
| appgateway\_http\_4xx\_errors\_id | id for monitor appgateway_http_4xx_errors |
| appgateway\_http\_5xx\_errors\_id | id for monitor appgateway_http_5xx_errors |
| appgateway\_status\_id | id for monitor appgateway_status |
| current\_connection\_id | id for monitor current_connection |
## Related documentation

View File

@ -0,0 +1,389 @@
# Azure App Gateway global variables
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
}
variable "prefix_slug" {
description = "Prefix string to prepend between brackets on every monitors names"
default = ""
}
# Azure App Gateway specific variables
# Monitoring App Gateway status
variable "status_enabled" {
description = "Flag to enable App Gateway status"
type = string
default = "true"
}
variable "status_extra_tags" {
description = "Extra tags for App Gateway status"
type = list(string)
default = []
}
variable "status_message" {
description = "Custom message for App Gateway status"
type = string
default = ""
}
variable "status_time_aggregator" {
description = "Monitor aggregator for App Gateway status [available values: min, max or avg]"
type = string
default = "max"
}
variable "status_timeframe" {
description = "Monitor timeframe for App Gateway status [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
# Monitoring App Gateway current_connections
variable "current_connection_enabled" {
description = "Flag to enable App Gateway current connections monitor"
type = string
default = "true"
}
variable "current_connection_extra_tags" {
description = "Extra tags for App Gateway current connections monitor"
type = list(string)
default = []
}
variable "current_connection_message" {
description = "Custom message for App Gateway current connections monitor"
type = string
default = ""
}
variable "current_connection_time_aggregator" {
description = "Monitor aggregator for App Gateway current connections [available values: min, max or avg]"
type = string
default = "max"
}
variable "current_connection_timeframe" {
description = "Monitor timeframe for App Gateway current connections [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
# Monitoring App Gateway failed_requests
variable "appgateway_backend_connect_time_enabled" {
description = "Flag to enable App Gateway backend_connect_time monitor"
type = string
default = "true"
}
variable "appgateway_backend_connect_time_extra_tags" {
description = "Extra tags for App Gateway backend_connect_time monitor"
type = list(string)
default = []
}
variable "appgateway_backend_connect_time_message" {
description = "Custom message for App Gateway backend_connect_time monitor"
type = string
default = ""
}
variable "appgateway_backend_connect_time_time_aggregator" {
description = "Monitor aggregator for App Gateway backend_connect_time [available values: min, max or avg]"
type = string
default = "max"
}
variable "appgateway_backend_connect_time_timeframe" {
description = "Monitor timeframe for App Gateway backend_connect_time [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_backend_connect_time_threshold_critical" {
default = 50
description = "Maximum critical backend_connect_time errors in milliseconds"
}
variable "appgateway_backend_connect_time_threshold_warning" {
default = 40
description = "Warning regarding backend_connect_time errors in milliseconds"
}
# Monitoring App Gateway failed_requests
variable "appgateway_failed_requests_enabled" {
description = "Flag to enable App Gateway failed requests monitor"
type = string
default = "true"
}
variable "appgateway_failed_requests_extra_tags" {
description = "Extra tags for App Gateway failed requests monitor"
type = list(string)
default = []
}
variable "appgateway_failed_requests_message" {
description = "Custom message for App Gateway failed requests monitor"
type = string
default = ""
}
variable "appgateway_failed_requests_time_aggregator" {
description = "Monitor aggregator for App Gateway failed requests [available values: min, max or avg]"
type = string
default = "min"
}
variable "appgateway_failed_requests_timeframe" {
description = "Monitor timeframe for App Gateway failed requests [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_failed_requests_threshold_critical" {
default = 95
description = "Maximum critical acceptable percent of failed errors"
}
variable "appgateway_failed_requests_threshold_warning" {
default = 80
description = "Warning regarding acceptable percent of failed errors"
}
# Monitoring App Gateway unhealthy_host_ratio
variable "appgateway_unhealthy_host_ratio_enabled" {
description = "Flag to enable App Gateway unhealthy host ratio monitor"
type = string
default = "true"
}
variable "appgateway_unhealthy_host_ratio_extra_tags" {
description = "Extra tags for App Gateway unhealthy host ratio monitor"
type = list(string)
default = []
}
variable "appgateway_unhealthy_host_ratio_message" {
description = "Custom message for App Gateway unhealthy host ratio monitor"
type = string
default = ""
}
variable "appgateway_unhealthy_host_ratio_time_aggregator" {
description = "Monitor aggregator for App Gateway unhealthy host ratio [available values: min, max or avg]"
type = string
default = "max"
}
variable "appgateway_unhealthy_host_ratio_timeframe" {
description = "Monitor timeframe for App Gateway unhealthy host ratio [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_unhealthy_host_ratio_threshold_critical" {
default = 75
description = "Maximum critical acceptable ratio of unhealthy host"
}
variable "appgateway_unhealthy_host_ratio_threshold_warning" {
default = 50
description = "Warning regarding acceptable ratio of unhealthy host"
}
# Monitoring App Gateway response_status 4xx
variable "appgateway_http_4xx_errors_enabled" {
description = "Flag to enable App Gateway http 4xx errors monitor"
type = string
default = "true"
}
variable "appgateway_http_4xx_errors_extra_tags" {
description = "Extra tags for App Gateway http 4xx errors monitor"
type = list(string)
default = []
}
variable "appgateway_http_4xx_errors_message" {
description = "Custom message for App Gateway http 4xx errors monitor"
type = string
default = ""
}
variable "appgateway_http_4xx_errors_time_aggregator" {
description = "Monitor aggregator for App Gateway http 4xx errors [available values: min, max or avg]"
type = string
default = "max"
}
variable "appgateway_http_4xx_errors_timeframe" {
description = "Monitor timeframe for App Gateway http 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_http_4xx_errors_threshold_critical" {
default = 95
description = "Maximum critical acceptable percent of 4xx error"
}
variable "appgateway_http_4xx_errors_threshold_warning" {
default = 80
description = "Warning regarding acceptable percent of 4xx error"
}
# Monitoring App Gateway response_status 5xx
variable "appgateway_http_5xx_errors_enabled" {
description = "Flag to enable App Gateway http 5xx errors monitor"
type = string
default = "true"
}
variable "appgateway_http_5xx_errors_extra_tags" {
description = "Extra tags for App Gateway http 5xx errors monitor"
type = list(string)
default = []
}
variable "appgateway_http_5xx_errors_message" {
description = "Custom message for App Gateway http 5xx errors monitor"
type = string
default = ""
}
variable "appgateway_http_5xx_errors_time_aggregator" {
description = "Monitor aggregator for App Gateway http 5xx errors [available values: min, max or avg]"
type = string
default = "max"
}
variable "appgateway_http_5xx_errors_timeframe" {
description = "Monitor timeframe for App Gateway http 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_http_5xx_errors_threshold_critical" {
default = 95
description = "Maximum critical acceptable percent of 5xx error"
}
variable "appgateway_http_5xx_errors_threshold_warning" {
default = 80
description = "Warning regarding acceptable percent of 5xx error"
}
# Monitoring App Gateway Backend response_status 4xx
variable "appgateway_backend_http_4xx_errors_enabled" {
description = "Flag to enable App Gateway http 4xx errors monitor"
type = string
default = "true"
}
variable "appgateway_backend_http_4xx_errors_extra_tags" {
description = "Extra tags for App Gateway http 4xx errors monitor"
type = list(string)
default = []
}
variable "appgateway_backend_http_4xx_errors_message" {
description = "Custom message for App Gateway http 4xx errors monitor"
type = string
default = ""
}
variable "appgateway_backend_http_4xx_errors_time_aggregator" {
description = "Monitor aggregator for App Gateway http 4xx errors [available values: min, max or avg]"
type = string
default = "max"
}
variable "appgateway_backend_http_4xx_errors_timeframe" {
description = "Monitor timeframe for App Gateway http 4xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_backend_http_4xx_errors_threshold_critical" {
default = 95
description = "Minimum critical acceptable percent of 4xx error"
}
variable "appgateway_backend_http_4xx_errors_threshold_warning" {
default = 80
description = "Warning regarding acceptable percent of 4xx error"
}
# Monitoring App Gateway Backend response_status 5xx
variable "appgateway_backend_http_5xx_errors_enabled" {
description = "Flag to enable App Gateway http 5xx errors monitor"
type = string
default = "true"
}
variable "appgateway_backend_http_5xx_errors_extra_tags" {
description = "Extra tags for App Gateway http 5xx errors monitor"
type = list(string)
default = []
}
variable "appgateway_backend_http_5xx_errors_message" {
description = "Custom message for App Gateway http 5xx errors monitor"
type = string
default = ""
}
variable "appgateway_backend_http_5xx_errors_time_aggregator" {
description = "Monitor aggregator for App Gateway http 5xx errors [available values: min, max or avg]"
type = string
default = "max"
}
variable "appgateway_backend_http_5xx_errors_timeframe" {
description = "Monitor timeframe for App Gateway http 5xx errors [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
type = string
default = "last_5m"
}
variable "appgateway_backend_http_5xx_errors_threshold_critical" {
default = 95
description = "Minimum critical acceptable percent of 5xx error"
}
variable "appgateway_backend_http_5xx_errors_threshold_warning" {
default = 80
description = "Warning regarding acceptable percent of 5xx error"
}

View File

@ -0,0 +1,53 @@
module "filter-tags" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "azure_app-gateway"
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-4xx-error" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "azure_app-gateway"
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
extra_tags = ["httpstatusgroup:4xx"]
}
module "filter-tags-5xx-error" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "azure_app-gateway"
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
extra_tags = ["httpstatusgroup:5xx"]
}
module "filter-tags-backend-4xx-error" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "azure_app-gateway"
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
extra_tags = ["httpstatusgroup:4xx"]
}
module "filter-tags-backend-5xx-error" {
source = "../../../common/filter-tags"
environment = var.environment
resource = "azure_app-gateway"
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
extra_tags = ["httpstatusgroup:5xx"]
}

View File

@ -0,0 +1,302 @@
# Monitoring App Gateway status
resource "datadog_monitor" "appgateway_status" {
count = var.status_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway is down"
message = coalesce(var.status_message, var.message)
type = "metric alert"
query = <<EOQ
${var.status_time_aggregator}(${var.status_timeframe}): (
avg:azure.network_applicationgateways.status${module.filter-tags.query_alert} by {resource_group,region,name}
) != 1
EOQ
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = true
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.status_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway current_connections
resource "datadog_monitor" "current_connection" {
count = var.current_connection_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway has no connection"
message = coalesce(var.current_connection_message, var.message)
type = "query alert"
query = <<EOQ
${var.current_connection_time_aggregator}(${var.current_connection_timeframe}):
azure.network_applicationgateways.current_connections${module.filter-tags.query_alert} by {resource_group,region,name} < 1
EOQ
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
notify_audit = false
timeout_h = 1
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.current_connection_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway backend_connect_time
resource "datadog_monitor" "appgateway_backend_connect_time" {
count = var.appgateway_backend_connect_time_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway backend connect time is too high {{#is_alert}}{{{comparator}}} {{threshold}}s ({{value}}s){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}s ({{value}}s){{/is_warning}}"
message = coalesce(var.appgateway_backend_connect_time_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_backend_connect_time_time_aggregator}(${var.appgateway_backend_connect_time_timeframe}):
sum:azure.network_applicationgateways.backend_connect_time${module.filter-tags.query_alert} by {resource_group,region,name,backendhttpsetting,backendpool,backendserver} > ${var.appgateway_backend_connect_time_threshold_critical}
EOQ
thresholds = {
critical = var.appgateway_backend_connect_time_threshold_critical
warning = var.appgateway_backend_connect_time_threshold_warning
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_backend_connect_time_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway failed_requests
resource "datadog_monitor" "appgateway_failed_requests" {
count = var.appgateway_failed_requests_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway failed requests {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.appgateway_failed_requests_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_failed_requests_time_aggregator}(${var.appgateway_failed_requests_timeframe}):
default((default(avg:azure.network_applicationgateways.failed_requests${module.filter-tags.query_alert} by {resource_group,region,name,backendsettingspool}.as_rate(), 0) /
default(avg:azure.network_applicationgateways.total_requests${module.filter-tags.query_alert} by {resource_group,region,name,backendsettingspool}.as_rate(),0)
* 100),0) > ${var.appgateway_failed_requests_threshold_critical}
EOQ
thresholds = {
critical = var.appgateway_failed_requests_threshold_critical
warning = var.appgateway_failed_requests_threshold_warning
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_failed_requests_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway unhealthy_host_ratio
resource "datadog_monitor" "appgateway_healthy_host_ratio" {
count = var.appgateway_unhealthy_host_ratio_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway backend unhealthy host ratio is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.appgateway_unhealthy_host_ratio_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_unhealthy_host_ratio_time_aggregator}(${var.appgateway_unhealthy_host_ratio_timeframe}):
sum:azure.network_applicationgateways.unhealthy_host_count${module.filter-tags.query_alert} by {resource_group,region,name,backendsettingspool} /
(sum:azure.network_applicationgateways.unhealthy_host_count${module.filter-tags.query_alert} by {resource_group,region,name,backendsettingspool} +
sum:azure.network_applicationgateways.healthy_host_count${module.filter-tags.query_alert} by {resource_group,region,name,backendsettingspool})
* 100 > ${var.appgateway_unhealthy_host_ratio_threshold_critical}
EOQ
thresholds = {
critical = var.appgateway_unhealthy_host_ratio_threshold_critical
warning = var.appgateway_unhealthy_host_ratio_threshold_warning
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
notify_audit = false
timeout_h = 0
include_tags = true
locked = false
require_full_window = false
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_unhealthy_host_ratio_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway response_status 4xx
resource "datadog_monitor" "appgateway_http_4xx_errors" {
count = var.appgateway_http_4xx_errors_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway HTTP 4xx errors rate is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.appgateway_http_4xx_errors_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_http_4xx_errors_time_aggregator}(${var.appgateway_http_4xx_errors_timeframe}):
default((default(sum:azure.network_applicationgateways.response_status${module.filter-tags-4xx-error.query_alert} by {resource_group,region,name}.as_rate(), 0) /
default(sum:azure.network_applicationgateways.response_status${module.filter-tags.query_alert} by {resource_group,region,name}.as_rate(),0)
* 100),0) > ${var.appgateway_http_4xx_errors_threshold_critical}
EOQ
thresholds = {
warning = var.appgateway_http_4xx_errors_threshold_warning
critical = var.appgateway_http_4xx_errors_threshold_critical
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
require_full_window = false
timeout_h = 1
include_tags = true
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_http_4xx_errors_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway response_status 5xx
resource "datadog_monitor" "appgateway_http_5xx_errors" {
count = var.appgateway_http_5xx_errors_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway HTTP 5xx errors rate is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.appgateway_http_5xx_errors_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_http_5xx_errors_time_aggregator}(${var.appgateway_http_5xx_errors_timeframe}):
default((default(sum:azure.network_applicationgateways.response_status${module.filter-tags-5xx-error.query_alert} by {resource_group,region,name}.as_rate(), 0) /
default(sum:azure.network_applicationgateways.response_status${module.filter-tags.query_alert} by {resource_group,region,name}.as_rate(),0)
* 100),0) > ${var.appgateway_http_5xx_errors_threshold_critical}
EOQ
thresholds = {
warning = var.appgateway_http_5xx_errors_threshold_warning
critical = var.appgateway_http_5xx_errors_threshold_critical
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
require_full_window = false
timeout_h = 1
include_tags = true
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_http_5xx_errors_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway Backend response_status 4xx
resource "datadog_monitor" "appgateway_backend_http_4xx_errors" {
count = var.appgateway_backend_http_4xx_errors_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway backend HTTP 4xx errors rate is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.appgateway_backend_http_4xx_errors_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_backend_http_4xx_errors_time_aggregator}(${var.appgateway_backend_http_4xx_errors_timeframe}):
default((default(sum:azure.network_applicationgateways.backend_response_status${module.filter-tags-backend-4xx-error.query_alert} by {resource_group,region,name,backendhttpsetting,backendpool,backendserver}.as_rate(), 0) /
default(sum:azure.network_applicationgateways.backend_response_status${module.filter-tags.query_alert} by {resource_group,region,name,backendhttpsetting,backendpool,backendserver}.as_rate(),0)
* 100),0) > ${var.appgateway_backend_http_4xx_errors_threshold_critical}
EOQ
thresholds = {
warning = var.appgateway_backend_http_4xx_errors_threshold_warning
critical = var.appgateway_backend_http_4xx_errors_threshold_critical
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
require_full_window = false
timeout_h = 1
include_tags = true
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_backend_http_4xx_errors_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}
# Monitoring App Gateway Backend response_status 5xx
resource "datadog_monitor" "appgateway_backend_http_5xx_errors" {
count = var.appgateway_backend_http_5xx_errors_enabled == "true" ? 1 : 0
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] App Gateway backend HTTP 5xx errors rate is too high {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
message = coalesce(var.appgateway_backend_http_5xx_errors_message, var.message)
type = "query alert"
query = <<EOQ
${var.appgateway_backend_http_5xx_errors_time_aggregator}(${var.appgateway_backend_http_5xx_errors_timeframe}):
default((default(sum:azure.network_applicationgateways.backend_response_status${module.filter-tags-backend-5xx-error.query_alert} by {resource_group,region,name,backendhttpsetting,backendpool,backendserver}.as_rate(), 0) /
default(sum:azure.network_applicationgateways.backend_response_status${module.filter-tags.query_alert} by {resource_group,region,name,backendhttpsetting,backendpool,backendserver}.as_rate(),0)
* 100),0) > ${var.appgateway_backend_http_5xx_errors_threshold_critical}
EOQ
thresholds = {
warning = var.appgateway_backend_http_5xx_errors_threshold_warning
critical = var.appgateway_backend_http_5xx_errors_threshold_critical
}
evaluation_delay = var.evaluation_delay
new_host_delay = var.new_host_delay
notify_no_data = false
renotify_interval = 0
require_full_window = false
timeout_h = 1
include_tags = true
tags = concat(["env:${var.environment}", "type:cloud", "provider:azure", "resource:app-gateway", "team:claranet", "created-by:terraform"], var.appgateway_backend_http_5xx_errors_extra_tags)
lifecycle {
ignore_changes = ["silenced"]
}
}

View File

@ -0,0 +1,45 @@
output "appgateway_backend_connect_time_id" {
description = "id for monitor appgateway_backend_connect_time"
value = datadog_monitor.appgateway_backend_connect_time.*.id
}
output "appgateway_backend_http_4xx_errors_id" {
description = "id for monitor appgateway_backend_http_4xx_errors"
value = datadog_monitor.appgateway_backend_http_4xx_errors.*.id
}
output "appgateway_backend_http_5xx_errors_id" {
description = "id for monitor appgateway_backend_http_5xx_errors"
value = datadog_monitor.appgateway_backend_http_5xx_errors.*.id
}
output "appgateway_failed_requests_id" {
description = "id for monitor appgateway_failed_requests"
value = datadog_monitor.appgateway_failed_requests.*.id
}
output "appgateway_healthy_host_ratio_id" {
description = "id for monitor appgateway_healthy_host_ratio"
value = datadog_monitor.appgateway_healthy_host_ratio.*.id
}
output "appgateway_http_4xx_errors_id" {
description = "id for monitor appgateway_http_4xx_errors"
value = datadog_monitor.appgateway_http_4xx_errors.*.id
}
output "appgateway_http_5xx_errors_id" {
description = "id for monitor appgateway_http_5xx_errors"
value = datadog_monitor.appgateway_http_5xx_errors.*.id
}
output "appgateway_status_id" {
description = "id for monitor appgateway_status"
value = datadog_monitor.appgateway_status.*.id
}
output "current_connection_id" {
description = "id for monitor current_connection"
value = datadog_monitor.current_connection.*.id
}