MON-498 Kong monitors: service check and treatment limit
This commit is contained in:
parent
d8437ee676
commit
39e81c3776
@ -201,6 +201,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
||||
- [redis](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/database/redis/)
|
||||
- [middleware](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/middleware/)
|
||||
- [apache](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/middleware/apache/)
|
||||
- [kong](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/middleware/kong/)
|
||||
- [nginx](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/middleware/nginx/)
|
||||
- [php-fpm](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/middleware/php-fpm/)
|
||||
- [system](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/system/)
|
||||
|
||||
26
middleware/kong/README.md
Normal file
26
middleware/kong/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
# MIDDLEWARE KONG DataDog monitors
|
||||
|
||||
## How to use this module
|
||||
|
||||
```
|
||||
module "datadog-monitors-middleware-kong" {
|
||||
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//middleware/kong?ref={revision}"
|
||||
|
||||
environment = var.environment
|
||||
message = module.datadog-message-alerting.alerting-message
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
Creates DataDog monitors with the following checks:
|
||||
|
||||
- Kong does not respond
|
||||
- Kong exceeded its treatment limit
|
||||
|
||||
|
||||
## Related documentation
|
||||
|
||||
Datadog Documentation https://docs.datadoghq.com/integrations/kong/
|
||||
|
||||
127
middleware/kong/inputs.tf
Normal file
127
middleware/kong/inputs.tf
Normal file
@ -0,0 +1,127 @@
|
||||
# Global Terraform
|
||||
variable "environment" {
|
||||
description = "Architecture Environment"
|
||||
type = string
|
||||
}
|
||||
|
||||
# Global DataDog
|
||||
variable "evaluation_delay" {
|
||||
description = "Delay in seconds for the metric evaluation"
|
||||
default = 15
|
||||
}
|
||||
|
||||
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 = ""
|
||||
}
|
||||
|
||||
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 = "*"
|
||||
}
|
||||
|
||||
variable "filter_tags_custom_excluded" {
|
||||
description = "Tags excluded for custom filtering when filter_tags_use_defaults is false"
|
||||
default = ""
|
||||
}
|
||||
|
||||
#
|
||||
# Not Responding
|
||||
#
|
||||
|
||||
variable "not_responding_enabled" {
|
||||
description = "Flag to enable Kong does not respond monitor"
|
||||
type = string
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "not_responding_message" {
|
||||
description = "Custom message for Kong does not respond monitor"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "not_responding_last" {
|
||||
description = "Parameter 'last' for the service check"
|
||||
type = string
|
||||
default = 6
|
||||
}
|
||||
|
||||
variable "not_responding_threshold_critical" {
|
||||
description = "Parameter 'last' for the service check"
|
||||
type = string
|
||||
default = 5
|
||||
}
|
||||
|
||||
variable "not_responding_no_data_timeframe" {
|
||||
description = "Kong does not respond monitor no data timeframe"
|
||||
type = string
|
||||
default = 10
|
||||
}
|
||||
|
||||
variable "not_responding_extra_tags" {
|
||||
description = "Extra tags for Kong does not respond monitor"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
#
|
||||
# treatment Limit
|
||||
#
|
||||
variable "treatment_limit_enabled" {
|
||||
description = "Flag to enable Kong Treatment Limit monitor"
|
||||
type = string
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "treatment_limit_message" {
|
||||
description = "Custom message for the Kong Treatment Limit monitor"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "treatment_limit_time_aggregator" {
|
||||
description = "Time aggregator for the Kong Treatment Limit monitor"
|
||||
type = string
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "treatment_limit_timeframe" {
|
||||
description = "Timeframe for the Kong Treatment Limit monitor"
|
||||
type = string
|
||||
default = "last_15m"
|
||||
}
|
||||
|
||||
variable "treatment_limit_threshold_warning" {
|
||||
description = "Docker Container Memory Usage warning threshold"
|
||||
type = string
|
||||
default = 0
|
||||
}
|
||||
|
||||
variable "treatment_limit_threshold_critical" {
|
||||
description = "Docker Container Memory Usage critical threshold"
|
||||
type = string
|
||||
default = 20
|
||||
}
|
||||
|
||||
variable "treatment_limit_extra_tags" {
|
||||
description = "Extra tags for Kong Treatment Limit monitor"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
|
||||
9
middleware/kong/modules.tf
Normal file
9
middleware/kong/modules.tf
Normal file
@ -0,0 +1,9 @@
|
||||
module "filter-tags" {
|
||||
source = "../../common/filter-tags"
|
||||
|
||||
environment = var.environment
|
||||
resource = "kong"
|
||||
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
|
||||
}
|
||||
69
middleware/kong/monitors-kong.tf
Normal file
69
middleware/kong/monitors-kong.tf
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# Service Check
|
||||
#
|
||||
resource "datadog_monitor" "not_responding" {
|
||||
count = var.not_responding_enabled == "true" ? 1 : 0
|
||||
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kong does not respond"
|
||||
message = coalesce(var.not_responding_message, var.message)
|
||||
type = "service check"
|
||||
|
||||
query = <<EOQ
|
||||
"kong.can_connect"${module.filter-tags.service_check}.by("kong_host","kong_port").last(${var.not_responding_last}).count_by_status()
|
||||
EOQ
|
||||
|
||||
thresholds = {
|
||||
critical = var.not_responding_threshold_critical
|
||||
}
|
||||
|
||||
new_host_delay = var.new_host_delay
|
||||
no_data_timeframe = var.not_responding_no_data_timeframe
|
||||
notify_no_data = true
|
||||
notify_audit = false
|
||||
locked = false
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
require_full_window = true
|
||||
renotify_interval = 0
|
||||
|
||||
tags = concat(["env:${var.environment}", "type:middleware", "provider:kong", "resource:kong", "team:claranet", "created-by:terraform"], var.not_responding_extra_tags)
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = ["silenced"]
|
||||
}
|
||||
}
|
||||
|
||||
resource "datadog_monitor" "treatment_limit" {
|
||||
count = var.treatment_limit_enabled == "true" ? 1 : 0
|
||||
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] Kong exceeded its treatment limit {{#is_alert}}{{{comparator}}} {{threshold}}% ({{value}}%){{/is_alert}}{{#is_warning}}{{{comparator}}} {{warn_threshold}}% ({{value}}%){{/is_warning}}"
|
||||
message = coalesce(var.treatment_limit_message, var.message)
|
||||
type = "query alert"
|
||||
|
||||
query = <<EOQ
|
||||
${var.treatment_limit_time_aggregator}(${var.treatment_limit_timeframe}):
|
||||
( min:kong.connections_handled${module.filter-tags.query_alert} by {host} - min:kong.connections_accepted${module.filter-tags.query_alert} by {host} )
|
||||
/ min:kong.connections_handled${module.filter-tags.query_alert} by {host} * 100
|
||||
> ${var.treatment_limit_threshold_critical}
|
||||
EOQ
|
||||
|
||||
thresholds = {
|
||||
warning = var.treatment_limit_threshold_warning
|
||||
critical = var.treatment_limit_threshold_critical
|
||||
}
|
||||
|
||||
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 = true
|
||||
|
||||
tags = concat(["env:${var.environment}", "type:middleware", "provider:kong", "resource:kong", "team:claranet", "created-by:terraform"], var.treatment_limit_extra_tags)
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = ["silenced"]
|
||||
}
|
||||
}
|
||||
|
||||
10
middleware/kong/outputs.tf
Normal file
10
middleware/kong/outputs.tf
Normal file
@ -0,0 +1,10 @@
|
||||
output "not_responding_id" {
|
||||
description = "id for monitor not_responding"
|
||||
value = datadog_monitor.not_responding.*.id
|
||||
}
|
||||
|
||||
output "treatment_limit_id" {
|
||||
description = "id for monitor treatment_limit"
|
||||
value = datadog_monitor.treatment_limit.*.id
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user