MON-248 add 4xx monitor
This commit is contained in:
parent
881a0fe78e
commit
efaa611202
@ -16,6 +16,7 @@ module "datadog-monitors-caas-kubernetes-ingress" {
|
|||||||
|
|
||||||
Creates DataDog monitors with the following checks:
|
Creates DataDog monitors with the following checks:
|
||||||
|
|
||||||
|
- Nginx Ingress 4xx errors
|
||||||
- Nginx Ingress 5xx errors
|
- Nginx Ingress 5xx errors
|
||||||
|
|
||||||
## Inputs
|
## Inputs
|
||||||
@ -27,12 +28,19 @@ Creates DataDog monitors with the following checks:
|
|||||||
| evaluation_delay | Delay in seconds for the metric evaluation | string | `15` | no |
|
| evaluation_delay | Delay in seconds for the metric evaluation | string | `15` | no |
|
||||||
| filter_tags_custom | Tags used for custom filtering when filter_tags_use_defaults is false | string | `*` | no |
|
| 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 |
|
| filter_tags_use_defaults | Use default filter tags convention | string | `true` | no |
|
||||||
|
| ingress_4xx_enabled | Flag to enable Ingress 4xx errors monitor | string | `true` | no |
|
||||||
|
| ingress_4xx_extra_tags | Extra tags for Ingress 4xx errors monitor | list | `<list>` | no |
|
||||||
|
| ingress_4xx_message | Message sent when an alert is triggered | string | `` | no |
|
||||||
|
| ingress_4xx_silenced | Groups to mute for Ingress 4xx errors monitor | map | `<map>` | no |
|
||||||
|
| ingress_4xx_threshold_critical | | string | `40` | no |
|
||||||
|
| ingress_4xx_threshold_warning | | string | `20` | no |
|
||||||
|
| ingress_4xx_timeframe | Monitor timeframe for Ingress 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 |
|
||||||
| ingress_5xx_enabled | Flag to enable Ingress 5xx errors monitor | string | `true` | no |
|
| ingress_5xx_enabled | Flag to enable Ingress 5xx errors monitor | string | `true` | no |
|
||||||
| ingress_5xx_extra_tags | Extra tags for Ingress 5xx errors monitor | list | `<list>` | no |
|
| ingress_5xx_extra_tags | Extra tags for Ingress 5xx errors monitor | list | `<list>` | no |
|
||||||
| ingress_5xx_message | Message sent when an alert is triggered | string | `` | no |
|
| ingress_5xx_message | Message sent when an alert is triggered | string | `` | no |
|
||||||
| ingress_5xx_silenced | Groups to mute for Ingress 5xx errors monitor | map | `<map>` | no |
|
| ingress_5xx_silenced | Groups to mute for Ingress 5xx errors monitor | map | `<map>` | no |
|
||||||
| ingress_5xx_threshold_critical | | string | `10` | no |
|
| ingress_5xx_threshold_critical | | string | `20` | no |
|
||||||
| ingress_5xx_threshold_warning | | string | `5` | no |
|
| ingress_5xx_threshold_warning | | string | `10` | no |
|
||||||
| ingress_5xx_timeframe | Monitor timeframe for Ingress 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 |
|
| ingress_5xx_timeframe | Monitor timeframe for Ingress 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 |
|
||||||
| message | Message sent when an alert is triggered | string | - | yes |
|
| message | Message sent when an alert is triggered | string | - | yes |
|
||||||
| new_host_delay | Delay in seconds before monitor new resource | string | `300` | no |
|
| new_host_delay | Delay in seconds before monitor new resource | string | `300` | no |
|
||||||
@ -41,7 +49,8 @@ Creates DataDog monitors with the following checks:
|
|||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
|------|-------------|
|
|------|-------------|
|
||||||
| Nginx_ingress_too_many_5xx_id | id for monitor Nginx_ingress_too_many_5xx |
|
| nginx_ingress_too_many_4xx_id | id for monitor nginx_ingress_too_many_4xx |
|
||||||
|
| nginx_ingress_too_many_5xx_id | id for monitor nginx_ingress_too_many_5xx |
|
||||||
|
|
||||||
Related documentation
|
Related documentation
|
||||||
---------------------
|
---------------------
|
||||||
|
|||||||
@ -61,12 +61,51 @@ variable "ingress_5xx_timeframe" {
|
|||||||
|
|
||||||
variable "ingress_5xx_threshold_critical" {
|
variable "ingress_5xx_threshold_critical" {
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "10"
|
default = "20"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ingress_5xx_threshold_warning" {
|
variable "ingress_5xx_threshold_warning" {
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "5"
|
default = "10"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ingress_4xx_silenced" {
|
||||||
|
description = "Groups to mute for Ingress 4xx errors monitor"
|
||||||
|
type = "map"
|
||||||
|
default = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ingress_4xx_enabled" {
|
||||||
|
description = "Flag to enable Ingress 4xx errors monitor"
|
||||||
|
type = "string"
|
||||||
|
default = "true"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ingress_4xx_extra_tags" {
|
||||||
|
description = "Extra tags for Ingress 4xx errors monitor"
|
||||||
|
type = "list"
|
||||||
|
default = []
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ingress_4xx_message" {
|
||||||
|
description = "Message sent when an alert is triggered"
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ingress_4xx_timeframe" {
|
||||||
|
description = "Monitor timeframe for Ingress 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 "ingress_4xx_threshold_critical" {
|
||||||
|
type = "string"
|
||||||
|
default = "40"
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "ingress_4xx_threshold_warning" {
|
||||||
|
type = "string"
|
||||||
|
default = "20"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "artificial_requests_count" {
|
variable "artificial_requests_count" {
|
||||||
|
|||||||
@ -17,3 +17,13 @@ module "filter-tags-5xx" {
|
|||||||
filter_tags_custom = "${var.filter_tags_custom}"
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
extra_tags = ["!upstream:upstream-default-backend,status_code:5xx"]
|
extra_tags = ["!upstream:upstream-default-backend,status_code:5xx"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module "filter-tags-4xx" {
|
||||||
|
source = "../../../common/filter-tags"
|
||||||
|
|
||||||
|
environment = "${var.environment}"
|
||||||
|
resource = "ingress"
|
||||||
|
filter_tags_use_defaults = "${var.filter_tags_use_defaults}"
|
||||||
|
filter_tags_custom = "${var.filter_tags_custom}"
|
||||||
|
extra_tags = ["!upstream:upstream-default-backend,status_code:4xx"]
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
resource "datadog_monitor" "Nginx_ingress_too_many_5xx" {
|
resource "datadog_monitor" "nginx_ingress_too_many_5xx" {
|
||||||
count = "${var.ingress_5xx_enabled ? 1 : 0}"
|
count = "${var.ingress_5xx_enabled ? 1 : 0}"
|
||||||
name = "[${var.environment}] Nginx Ingress 5xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
name = "[${var.environment}] Nginx Ingress 5xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||||
message = "${coalesce(var.ingress_5xx_message, var.message)}"
|
message = "${coalesce(var.ingress_5xx_message, var.message)}"
|
||||||
@ -33,3 +33,39 @@ resource "datadog_monitor" "Nginx_ingress_too_many_5xx" {
|
|||||||
|
|
||||||
tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", "${var.ingress_5xx_extra_tags}"]
|
tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", "${var.ingress_5xx_extra_tags}"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "datadog_monitor" "nginx_ingress_too_many_4xx" {
|
||||||
|
count = "${var.ingress_4xx_enabled ? 1 : 0}"
|
||||||
|
name = "[${var.environment}] Nginx Ingress 4xx errors {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||||
|
message = "${coalesce(var.ingress_4xx_message, var.message)}"
|
||||||
|
|
||||||
|
query = <<EOF
|
||||||
|
sum(${var.ingress_4xx_timeframe}): (
|
||||||
|
default(
|
||||||
|
avg:nginx_ingress.nginx_upstream_responses_total${module.filter-tags-4xx.query_alert} by {upstream,ingress_class} /
|
||||||
|
(avg:nginx_ingress.nginx_upstream_requests_total${module.filter-tags.query_alert} by {upstream,ingress_class} + ${var.artificial_requests_count}),
|
||||||
|
0) * 100
|
||||||
|
) > ${var.ingress_4xx_threshold_critical}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
type = "metric alert"
|
||||||
|
|
||||||
|
thresholds {
|
||||||
|
warning = "${var.ingress_4xx_threshold_warning}"
|
||||||
|
critical = "${var.ingress_4xx_threshold_critical}"
|
||||||
|
}
|
||||||
|
|
||||||
|
notify_no_data = false
|
||||||
|
evaluation_delay = "${var.evaluation_delay}"
|
||||||
|
new_host_delay = "${var.new_host_delay}"
|
||||||
|
renotify_interval = 0
|
||||||
|
notify_audit = false
|
||||||
|
timeout_h = 0
|
||||||
|
include_tags = true
|
||||||
|
locked = false
|
||||||
|
require_full_window = true
|
||||||
|
|
||||||
|
silenced = "${var.ingress_4xx_silenced}"
|
||||||
|
|
||||||
|
tags = ["env:${var.environment}", "type:caas", "provider:prometheus", "resource:nginx-ingress-controller", "team:claranet", "created-by:terraform", "${var.ingress_4xx_extra_tags}"]
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
output "Nginx_ingress_too_many_5xx_id" {
|
output "nginx_ingress_too_many_5xx_id" {
|
||||||
description = "id for monitor Nginx_ingress_too_many_5xx"
|
description = "id for monitor nginx_ingress_too_many_5xx"
|
||||||
value = "${datadog_monitor.Nginx_ingress_too_many_5xx.*.id}"
|
value = "${datadog_monitor.nginx_ingress_too_many_5xx.*.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
output "nginx_ingress_too_many_4xx_id" {
|
||||||
|
description = "id for monitor nginx_ingress_too_many_4xx"
|
||||||
|
value = "${datadog_monitor.nginx_ingress_too_many_4xx.*.id}"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user