diff --git a/cloud/azure/stream-analytics/README.md b/cloud/azure/stream-analytics/README.md new file mode 100644 index 0000000..dca299b --- /dev/null +++ b/cloud/azure/stream-analytics/README.md @@ -0,0 +1,41 @@ +Azure Stream Analytics DataDog monitors +======================================= + +How to use this module +---------------------- + +``` +module "datadog-monitors-azure-redis" { + source = "git::ssh://git@bitbucket.org/morea/terraform.feature.datadog.git//cloud/azure/stream-analytics?ref={revision}" + + message = "${module.datadog-message-alerting.alerting-message}" + environment = "${var.environment}" + subscription_id = "${var.subscription_id}" +} +``` + +Inputs +------ + +| Name | Description | Type | Default | Required | +|------|-------------|:----:|:-----:|:-----:| +| conversion_errors_threshold_critical | Conversion errors limit (critical threshold) | string | `10` | no | +| conversion_errors_threshold_warning | Conversion errors limit (warning threshold) | string | `0` | no | +| delay | Delay in seconds for the metric evaluation | string | `600` | no | +| environment | Architecture environment | string | - | yes | +| function_requests_threshold_critical | Failed Function Request rate limit (critical threshold) | string | `10` | no | +| function_requests_threshold_warning | Failed Function Request rate limit (warning threshold) | string | `0` | no | +| message | Message sent when a monitor is triggered | string | - | yes | +| provider | What is the monitored provider | string | azure | no | +| runtime_errors_threshold_critical | | string | `10` | no | +| runtime_errors_threshold_warning | | string | `0` | no | +| su_utilization_threshold_critical | | string | `80` | no | +| su_utilization_threshold_warning | Monitor specific | string | `60` | no | +| service | What is the monitored service | string | storage | no | +| subscription_id | Azure account id used as filter for monitors | string | - | yes | +| use_filter_tags | Filter the data with service tags if true | string | `true` | no | + +Related documentation +--------------------- + +DataDog documentation: [https://docs.datadoghq.com/integrations/azure/](https://docs.datadoghq.com/integrations/azure/) diff --git a/cloud/azure/stream-analytics/inputs.tf b/cloud/azure/stream-analytics/inputs.tf new file mode 100644 index 0000000..ae1186a --- /dev/null +++ b/cloud/azure/stream-analytics/inputs.tf @@ -0,0 +1,66 @@ +# Global Terraform +variable "environment" { + description = "Architecture environment" + type = "string" +} + +# Global DataDog +variable "message" { + description = "Message sent when a Redis monitor is triggered" +} + +variable "delay" { + description = "Delay in seconds for the metric evaluation" + default = 600 +} + +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 = "*" +} + +# Azure Stream Analytics specific +variable "su_utilization_threshold_warning" { + description = "Streaming Unit utilization rate limit (warning threshold)" + default = 60 +} + +variable "su_utilization_threshold_critical" { + description = "Streaming Unit utilization rate limit (critical threshold)" + default = 80 +} + +variable "function_requests_threshold_warning" { + description = "Failed Function Request rate limit (warning threshold)" + default = 0 +} + +variable "failed_function_requests_threshold_critical" { + description = "Failed Function Request rate limit (critical threshold)" + default = 10 +} + +variable "conversion_errors_threshold_warning" { + description = "Conversion errors limit (warning threshold)" + default = 0 +} + +variable "conversion_errors_threshold_critical" { + description = "Conversion errors limit (critical threshold)" + default = 10 +} + +variable "runtime_errors_threshold_warning" { + description = "Runtime errors limit (warning threshold)" + default = 0 +} + +variable "runtime_errors_threshold_critical" { + description = "Runtime errors limit (critical threshold)" + default = 10 +} diff --git a/cloud/azure/stream-analytics/monitors-stream-analytics.tf b/cloud/azure/stream-analytics/monitors-stream-analytics.tf new file mode 100644 index 0000000..f72af1f --- /dev/null +++ b/cloud/azure/stream-analytics/monitors-stream-analytics.tf @@ -0,0 +1,147 @@ +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.filter_tags_use_defaults == "true" ? format("dd_monitoring:enabled,dd_azure_streamanalytics:enabled,env:%s", var.environment) : "${var.filter_tags_custom}"}" + } +} + +resource "datadog_monitor" "status" { + name = "[${var.environment}] Stream Analytics Status is not ok on {{name}}" + message = "${var.message}" + + query = < ${var.su_utilization_threshold_critical} + EOF + type = "metric alert" + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + thresholds { + warning = "${var.su_utilization_threshold_warning}" + critical = "${var.su_utilization_threshold_critical}" + } + + tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"] +} + +resource "datadog_monitor" "failed_function_requests" { + name = "[${var.environment}] Stream Analytics more than ${var.failed_function_requests_threshold_critical} failed function requests on {{name}}" + message = "${var.message}" + + query = < ${var.failed_function_requests_threshold_critical} + EOF + type = "metric alert" + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 60 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + thresholds { + warning = "${var.function_requests_threshold_warning}" + critical = "${var.failed_function_requests_threshold_critical}" + } + + tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"] +} + +resource "datadog_monitor" "conversion_errors" { + name = "[${var.environment}] Stream Analytics more than ${var.conversion_errors_threshold_critical} conversion errors on {{name}}" + message = "${var.message}" + + query = < ${var.conversion_errors_threshold_critical} + EOF + type = "metric alert" + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + thresholds { + warning = "${var.conversion_errors_threshold_warning}" + critical = "${var.conversion_errors_threshold_critical}" + } + + tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"] +} + +resource "datadog_monitor" "runtime_errors" { + name = "[${var.environment}] Stream Analytics more than ${var.runtime_errors_threshold_critical} runtime errors on {{name}}" + message = "${var.message}" + + query = < ${var.runtime_errors_threshold_critical} + EOF + type = "metric alert" + + notify_no_data = false + evaluation_delay = "${var.delay}" + renotify_interval = 0 + notify_audit = false + timeout_h = 0 + include_tags = true + locked = false + require_full_window = true + new_host_delay = "${var.delay}" + no_data_timeframe = 20 + thresholds { + warning = "${var.runtime_errors_threshold_warning}" + critical = "${var.runtime_errors_threshold_critical}" + } + + tags = ["env:${var.environment}", "resource:streamanalytics", "team:azure", "provider:azure"] +}