Resolve MON-364 "Monitors for aws nlb"
This commit is contained in:
parent
e6e6fd620f
commit
038989de34
@ -151,6 +151,7 @@ The `//` is very important, it's a terraform specific syntax used to separate gi
|
||||
- [elb](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/elb/)
|
||||
- [kinesis-firehose](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/kinesis-firehose/)
|
||||
- [lambda](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/lambda/)
|
||||
- [nlb](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/nlb/)
|
||||
- [rds](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/)
|
||||
- [aurora](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/aurora/)
|
||||
- [mysql](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/cloud/aws/rds/aurora/mysql/)
|
||||
|
||||
49
cloud/aws/nlb/README.md
Normal file
49
cloud/aws/nlb/README.md
Normal file
@ -0,0 +1,49 @@
|
||||
# CLOUD AWS NLB DataDog monitors
|
||||
|
||||
## How to use this module
|
||||
|
||||
```
|
||||
module "datadog-monitors-cloud-aws-nlb" {
|
||||
source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//cloud/aws/nlb?ref={revision}"
|
||||
|
||||
environment = var.environment
|
||||
message = module.datadog-message-alerting.alerting-message
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Purpose
|
||||
|
||||
Creates DataDog monitors with the following checks:
|
||||
|
||||
- NLB healthy instances
|
||||
|
||||
## 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 |
|
||||
| nlb\_no\_healthy\_instances\_enabled | Flag to enable NLB no healthy instances monitor | string | `"true"` | no |
|
||||
| nlb\_no\_healthy\_instances\_extra\_tags | Extra tags for NLB no healthy instances monitor | list(string) | `[]` | no |
|
||||
| nlb\_no\_healthy\_instances\_message | Custom message for NLB no healthy instances monitor | string | `""` | no |
|
||||
| nlb\_no\_healthy\_instances\_time\_aggregator | Monitor aggregator for NLB no healthy instances [available values: min, max or avg] | string | `"min"` | no |
|
||||
| nlb\_no\_healthy\_instances\_timeframe | Monitor timeframe for NLB no healthy instances [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`] | string | `"last_5m"` | no |
|
||||
| prefix\_slug | Prefix string to prepend between brackets on every monitors names | string | `""` | no |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| NLB\_no\_healthy\_instances\_id | id for monitor NLB_no_healthy_instances |
|
||||
|
||||
## Related documentation
|
||||
|
||||
DataDog blog: [https://www.datadoghq.com/blog/monitor-aws-network-load-balancer/](https://www.datadoghq.com/blog/monitor-aws-network-load-balancer/)
|
||||
|
||||
AWS NLB metrics documentation: [https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-cloudwatch-metrics.html](https://docs.aws.amazon.com/elasticloadbalancing/latest/network/load-balancer-cloudwatch-metrics.html)
|
||||
73
cloud/aws/nlb/inputs.tf
Normal file
73
cloud/aws/nlb/inputs.tf
Normal file
@ -0,0 +1,73 @@
|
||||
# Datadog 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 = ""
|
||||
}
|
||||
|
||||
# Datadog monitors variables
|
||||
|
||||
variable "nlb_no_healthy_instances_enabled" {
|
||||
description = "Flag to enable NLB no healthy instances monitor"
|
||||
type = string
|
||||
default = "true"
|
||||
}
|
||||
|
||||
variable "nlb_no_healthy_instances_extra_tags" {
|
||||
description = "Extra tags for NLB no healthy instances monitor"
|
||||
type = list(string)
|
||||
default = []
|
||||
}
|
||||
|
||||
variable "nlb_no_healthy_instances_message" {
|
||||
description = "Custom message for NLB no healthy instances monitor"
|
||||
type = string
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "nlb_no_healthy_instances_time_aggregator" {
|
||||
description = "Monitor aggregator for NLB no healthy instances [available values: min, max or avg]"
|
||||
type = string
|
||||
default = "min"
|
||||
}
|
||||
|
||||
variable "nlb_no_healthy_instances_timeframe" {
|
||||
description = "Monitor timeframe for NLB no healthy instances [available values: `last_#m` (1, 5, 10, 15, or 30), `last_#h` (1, 2, or 4), or `last_1d`]"
|
||||
type = string
|
||||
default = "last_5m"
|
||||
}
|
||||
|
||||
10
cloud/aws/nlb/modules.tf
Normal file
10
cloud/aws/nlb/modules.tf
Normal file
@ -0,0 +1,10 @@
|
||||
module "filter-tags" {
|
||||
source = "../../../common/filter-tags"
|
||||
|
||||
environment = var.environment
|
||||
resource = "aws_nlb"
|
||||
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
|
||||
}
|
||||
|
||||
34
cloud/aws/nlb/monitors-nlb.tf
Normal file
34
cloud/aws/nlb/monitors-nlb.tf
Normal file
@ -0,0 +1,34 @@
|
||||
resource "datadog_monitor" "NLB_no_healthy_instances" {
|
||||
count = var.nlb_no_healthy_instances_enabled == "true" ? 1 : 0
|
||||
name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] NLB healthy instances {{#is_alert}}is at 0{{/is_alert}}{{#is_warning}}is at {{value}}%%{{/is_warning}}"
|
||||
message = coalesce(var.nlb_no_healthy_instances_message, var.message)
|
||||
type = "query alert"
|
||||
|
||||
query = <<EOQ
|
||||
${var.nlb_no_healthy_instances_time_aggregator}(${var.nlb_no_healthy_instances_timeframe}): (
|
||||
sum:aws.networkelb.healthy_host_count.minimum${module.filter-tags.query_alert} by {region,loadbalancer} / (
|
||||
sum:aws.networkelb.healthy_host_count.minimum${module.filter-tags.query_alert} by {region,loadbalancer} +
|
||||
sum:aws.networkelb.un_healthy_host_count.maximum${module.filter-tags.query_alert} by {region,loadbalancer} )
|
||||
) * 100 < 1
|
||||
EOQ
|
||||
|
||||
thresholds = {
|
||||
critical = 1
|
||||
warning = 100
|
||||
}
|
||||
|
||||
evaluation_delay = var.evaluation_delay
|
||||
new_host_delay = var.new_host_delay
|
||||
notify_no_data = true
|
||||
renotify_interval = 0
|
||||
require_full_window = false
|
||||
timeout_h = 0
|
||||
include_tags = true
|
||||
|
||||
tags = concat(["env:${var.environment}", "type:cloud", "provider:aws", "resource:nlb", "team:claranet", "created-by:terraform"], var.nlb_no_healthy_instances_extra_tags)
|
||||
|
||||
lifecycle {
|
||||
ignore_changes = ["silenced"]
|
||||
}
|
||||
}
|
||||
|
||||
5
cloud/aws/nlb/outputs.tf
Normal file
5
cloud/aws/nlb/outputs.tf
Normal file
@ -0,0 +1,5 @@
|
||||
output "NLB_no_healthy_instances_id" {
|
||||
description = "id for monitor NLB_no_healthy_instances"
|
||||
value = datadog_monitor.NLB_no_healthy_instances.*.id
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user