From 5c4b7dea0640661ecfd7629ddbc0ff1071962163 Mon Sep 17 00:00:00 2001 From: Rafael Romero Carmona Date: Tue, 20 Aug 2019 11:31:54 +0100 Subject: [PATCH] MON-499: set of monitors using integrations http_check, dns_check and tls --- README.md | 4 + network/dns/README.md | 24 ++++ network/dns/inputs.tf | 85 +++++++++++++ network/dns/modules.tf | 9 ++ network/dns/monitors-dns.tf | 34 +++++ network/dns/outputs.tf | 5 + network/http/README.md | 26 ++++ network/http/inputs.tf | 181 +++++++++++++++++++++++++++ network/http/modules.tf | 9 ++ network/http/monitors-http.tf | 107 ++++++++++++++++ network/http/outputs.tf | 15 +++ network/tls/README.md | 28 +++++ network/tls/inputs.tf | 226 ++++++++++++++++++++++++++++++++++ network/tls/modules.tf | 9 ++ network/tls/monitors-tls.tf | 143 +++++++++++++++++++++ network/tls/outputs.tf | 20 +++ 16 files changed, 925 insertions(+) create mode 100644 network/dns/README.md create mode 100644 network/dns/inputs.tf create mode 100644 network/dns/modules.tf create mode 100644 network/dns/monitors-dns.tf create mode 100644 network/dns/outputs.tf create mode 100644 network/http/README.md create mode 100644 network/http/inputs.tf create mode 100644 network/http/modules.tf create mode 100644 network/http/monitors-http.tf create mode 100644 network/http/outputs.tf create mode 100644 network/tls/README.md create mode 100644 network/tls/inputs.tf create mode 100644 network/tls/modules.tf create mode 100644 network/tls/monitors-tls.tf create mode 100644 network/tls/outputs.tf diff --git a/README.md b/README.md index ab56880..2c4f1f5 100644 --- a/README.md +++ b/README.md @@ -200,6 +200,10 @@ The `//` is very important, it's a terraform specific syntax used to separate gi - [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/) +- [network](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/network/) + - [dns](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/network/dns/) + - [http](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/network/http/) + - [tls](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/network/tls/) - [saas](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/saas/) - [new-relic](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/saas/new-relic/) - [system](https://git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors/tree/master/system/) diff --git a/network/dns/README.md b/network/dns/README.md new file mode 100644 index 0000000..8d459a7 --- /dev/null +++ b/network/dns/README.md @@ -0,0 +1,24 @@ +# NETWORK DNS DataDog monitors + +## How to use this module + +``` +module "datadog-monitors-network-dns" { + source = "git::ssh://git@git.fr.clara.net/claranet/pt-monitoring/projects/datadog/terraform/monitors.git//network/dns?ref={revision}" + + environment = var.environment + message = module.datadog-message-alerting.alerting-message +} + +``` + +## Purpose + +Creates DataDog monitors with the following checks: + +- DNS cannot resolve + + +## Related documentation + +- Datadog Documentation https://docs.datadoghq.com/integrations/dns_check/ diff --git a/network/dns/inputs.tf b/network/dns/inputs.tf new file mode 100644 index 0000000..dfd4a03 --- /dev/null +++ b/network/dns/inputs.tf @@ -0,0 +1,85 @@ +# 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 = "" +} + +# +# Cannot Resolve +# +variable "cannot_resolve_enabled" { + description = "Flag to enable DNS cannot resolve monitor" + type = string + default = "true" +} + +variable "cannot_resolve_message" { + description = "Custom message for DNS cannot resolve monitor" + type = string + default = "" +} + +variable "cannot_resolve_last" { + description = "Parameter 'last' for the service check" + type = string + default = 6 +} + +variable "cannot_resolve_threshold_warning" { + description = "DNS cannot resolve monitor (warning threshold)" + type = string + default = 3 +} + +variable "cannot_resolve_threshold_critical" { + description = "DNS cannot resolve monitor (warning threshold)" + type = string + default = 5 +} + +variable "cannot_resolve_no_data_timeframe" { + description = "DNS cannot resolve monitor no data timeframe" + type = string + default = 10 +} + +variable "cannot_resolve_extra_tags" { + description = "Extra tags for DNS cannot resolve monitor" + type = list(string) + default = [] +} \ No newline at end of file diff --git a/network/dns/modules.tf b/network/dns/modules.tf new file mode 100644 index 0000000..03747be --- /dev/null +++ b/network/dns/modules.tf @@ -0,0 +1,9 @@ +module "filter-tags" { + source = "../../common/filter-tags" + + environment = var.environment + resource = "dns" + 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 +} diff --git a/network/dns/monitors-dns.tf b/network/dns/monitors-dns.tf new file mode 100644 index 0000000..48f1c8c --- /dev/null +++ b/network/dns/monitors-dns.tf @@ -0,0 +1,34 @@ +# +# Service Check +# +resource "datadog_monitor" "cannot_resolve" { + count = var.cannot_resolve_enabled == "true" ? 1 : 0 + name = "${var.prefix_slug == "" ? "" : "[${var.prefix_slug}]"}[${var.environment}] DNS cannot resolve" + message = coalesce(var.cannot_resolve_message, var.message) + type = "service check" + + query = <