From 1a278fc81c90e853c0493132cd4f3e3f89858334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Respaut?= Date: Tue, 31 Oct 2017 12:04:35 +0100 Subject: [PATCH] MON-78: Fixup use filter tag usage --- .../monitors-stream-analytics.tf | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cloud/azure/stream-analytics/monitors-stream-analytics.tf b/cloud/azure/stream-analytics/monitors-stream-analytics.tf index 6ca7717..0972bd4 100644 --- a/cloud/azure/stream-analytics/monitors-stream-analytics.tf +++ b/cloud/azure/stream-analytics/monitors-stream-analytics.tf @@ -1,8 +1,16 @@ +data "template_file" "filter" { + template = "$${filter}" + + vars { + filter = "${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_stream_analytics:enabled,env:%s", var.environment) : "*"}" + } +} + resource "datadog_monitor" "su_utilization" { name = "[${var.environment}] Streaming Units utilization at more than ${var.su_utilization_threshold_critical}% on {{name}}" message = "${var.message}" - query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.resource_utilization{${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_eventhub:enabled,env:%s", var.environment) : "*"}} by {name,resource_group} > ${var.su_utilization_threshold_critical}" + query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.resource_utilization{${data.template_file.filter.rendered}} by {name,resource_group} > ${var.su_utilization_threshold_critical}" type = "query alert" notify_no_data = "${var.notify_no_data}" @@ -25,7 +33,7 @@ resource "datadog_monitor" "failed_function_requests" { name = "[${var.environment}] More than ${var.function_requests_threshold_critical} failed function requests on {{name}}" message = "${var.message}" - query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.aml_callout_failed_requests{${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_eventhub:enabled,env:%s", var.environment) : "*"}} by {name,resource_group} > ${var.function_requests_threshold_critical}" + query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.aml_callout_failed_requests{${data.template_file.filter.rendered}} by {name,resource_group} > ${var.function_requests_threshold_critical}" type = "query alert" notify_no_data = "${var.notify_no_data}" @@ -48,7 +56,7 @@ resource "datadog_monitor" "conversion_errors" { name = "[${var.environment}] More than ${var.conversion_errors_threshold_critical} conversion errors on {{name}}" message = "${var.message}" - query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.conversion_errors{${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_stream_analytics:enabled,env:%s", var.environment) : "*"}} by {name,resource_group} > ${var.conversion_errors_threshold_critical}" + query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.conversion_errors{${data.template_file.filter.rendered}} by {name,resource_group} > ${var.conversion_errors_threshold_critical}" type = "query alert" notify_no_data = "${var.notify_no_data}" @@ -71,7 +79,7 @@ resource "datadog_monitor" "runtime_errors" { name = "[${var.environment}] More than ${var.runtime_errors_threshold_critical} runtime errors on {{name}}" message = "${var.message}" - query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.errors{${var.use_filter_tags == "true" ? format("dd_monitoring:enabled,dd_azure_eventhub:enabled,env:%s", var.environment) : "*"}} by {name,resource_group} > ${var.runtime_errors_threshold_critical}" + query = "avg(last_5m):avg:azure.streamanalytics_streamingjobs.errors{${data.template_file.filter.rendered}} by {name,resource_group} > ${var.runtime_errors_threshold_critical}" type = "query alert" notify_no_data = "${var.notify_no_data}"