Merged in MON-91-remove-aws-vpn-metrics-tags (pull request #95)

MON-91 Monitor with VPN tunnel scope and remove custom metrics tags since they are not fetched

Approved-by: Jérôme Respaut <shr3ps@gmail.com>
Approved-by: Laurent Piroelle <laurent.piroelle@fr.clara.net>
Approved-by: Alexandre Gaillet <alexandre.gaillet@fr.clara.net>
Approved-by: Quentin Manfroi <quentin.manfroi@yahoo.fr>
This commit is contained in:
Laurent Piroelle 2018-08-09 09:53:55 +00:00 committed by Quentin Manfroi
commit d391733ae9
3 changed files with 6 additions and 20 deletions

View File

@ -16,7 +16,7 @@ module "datadog-monitors-cloud-aws-vpn" {
Creates DataDog monitors with the following checks:
- VPN Down
- VPN tunnel down
## Inputs
@ -24,8 +24,7 @@ Creates DataDog monitors with the following checks:
|------|-------------|:----:|:-----:|:-----:|
| delay | Delay in seconds for the metric evaluation | string | `900` | no |
| environment | Architecture Environment | string | - | yes |
| 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 | Tags used for metrics filtering | string | `*` | no |
| message | Message sent when an alert is triggered | string | - | yes |
| vpn_status_message | Custom message for VPN status monitor | string | `` | no |
| vpn_status_silenced | Groups to mute for VPN status monitor | map | `<map>` | no |

View File

@ -14,13 +14,8 @@ 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"
variable "filter_tags" {
description = "Tags used for metrics filtering"
default = "*"
}

View File

@ -1,18 +1,10 @@
data "template_file" "filter" {
template = "$${filter}"
vars {
filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_aws_vpn:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}"
}
}
resource "datadog_monitor" "VPN_status" {
name = "[${var.environment}] VPN Down"
name = "[${var.environment}] VPN tunnel down"
message = "${coalesce(var.vpn_status_message, var.message)}"
query = <<EOF
${var.vpn_status_time_aggregator}(${var.vpn_status_timeframe}): (
avg:aws.vpn.tunnel_state{${data.template_file.filter.rendered}} by {region,name}
min:aws.vpn.tunnel_state{${var.filter_tags}} by {region,tunnelipaddress}
) < 1
EOF