From 07f2df9f49831d8af57036612b5f69c6fbd4cc96 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 17 Sep 2018 14:16:45 +0200 Subject: [PATCH] MON-304 add default function to latencies --- cloud/aws/alb/monitors-alb.tf | 46 ++++++++++++---------------- cloud/aws/apigateway/monitors-api.tf | 6 ++-- cloud/aws/elb/monitors-elb.tf | 46 ++++++++++++---------------- 3 files changed, 41 insertions(+), 57 deletions(-) diff --git a/cloud/aws/alb/monitors-alb.tf b/cloud/aws/alb/monitors-alb.tf index c57da93..124ed57 100644 --- a/cloud/aws/alb/monitors-alb.tf +++ b/cloud/aws/alb/monitors-alb.tf @@ -35,9 +35,9 @@ resource "datadog_monitor" "ALB_latency" { message = "${coalesce(var.latency_message, var.message)}" query = < ${var.latency_threshold_critical} + ${var.latency_time_aggregator}(${var.latency_timeframe}): + default(avg:aws.applicationelb.target_response_time.average${module.filter-tags.query_alert} by {region,loadbalancer}, 0) + > ${var.latency_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" @@ -66,12 +66,10 @@ resource "datadog_monitor" "ALB_httpcode_5xx" { message = "${coalesce(var.httpcode_alb_5xx_message, var.message)}" query = < ${var.httpcode_alb_5xx_threshold_critical} + sum(${var.httpcode_alb_5xx_timeframe}): + default(avg:aws.applicationelb.httpcode_elb_5xx${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) / ( + default(avg:aws.applicationelb.request_count${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.httpcode_alb_5xx_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" @@ -100,12 +98,10 @@ resource "datadog_monitor" "ALB_httpcode_4xx" { message = "${coalesce(var.httpcode_alb_4xx_message, var.message)}" query = < ${var.httpcode_alb_4xx_threshold_critical} + sum(${var.httpcode_alb_4xx_timeframe}): + default(avg:aws.applicationelb.httpcode_elb_4xx${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) / ( + default(avg:aws.applicationelb.request_count${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.httpcode_alb_4xx_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" @@ -134,12 +130,10 @@ resource "datadog_monitor" "ALB_httpcode_target_5xx" { message = "${coalesce(var.httpcode_target_5xx_message, var.message)}" query = < ${var.httpcode_target_5xx_threshold_critical} + sum(${var.httpcode_target_5xx_timeframe}): + default(avg:aws.applicationelb.httpcode_target_5xx${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) / ( + default(avg:aws.applicationelb.request_count${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.httpcode_target_5xx_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" @@ -168,12 +162,10 @@ resource "datadog_monitor" "ALB_httpcode_target_4xx" { message = "${coalesce(var.httpcode_target_4xx_message, var.message)}" query = < ${var.httpcode_target_4xx_threshold_critical} + sum(${var.httpcode_target_4xx_timeframe}): + default(avg:aws.applicationelb.httpcode_target_4xx${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) / ( + default(avg:aws.applicationelb.request_count${module.filter-tags.query_alert} by {region,loadbalancer}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.httpcode_target_4xx_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" diff --git a/cloud/aws/apigateway/monitors-api.tf b/cloud/aws/apigateway/monitors-api.tf index e19b7ec..4916f9f 100644 --- a/cloud/aws/apigateway/monitors-api.tf +++ b/cloud/aws/apigateway/monitors-api.tf @@ -6,9 +6,9 @@ resource "datadog_monitor" "API_Gateway_latency" { message = "${coalesce(var.latency_message, var.message)}" query = < ${var.latency_threshold_critical} + ${var.latency_time_aggregator}(${var.latency_timeframe}): + default(avg:aws.apigateway.latency{${var.filter_tags}} by {region,apiname}) + > ${var.latency_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" diff --git a/cloud/aws/elb/monitors-elb.tf b/cloud/aws/elb/monitors-elb.tf index 62bbcf4..7e25fbb 100644 --- a/cloud/aws/elb/monitors-elb.tf +++ b/cloud/aws/elb/monitors-elb.tf @@ -32,12 +32,10 @@ resource "datadog_monitor" "ELB_too_much_4xx" { message = "${coalesce(var.elb_4xx_message, var.message)}" query = < ${var.elb_4xx_threshold_critical} + sum(${var.elb_4xx_timeframe}): + default(avg:aws.elb.httpcode_elb_4xx${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) / ( + default(avg:aws.elb.request_count${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.elb_4xx_threshold_critical} EOF type = "metric alert" @@ -68,12 +66,10 @@ resource "datadog_monitor" "ELB_too_much_5xx" { message = "${coalesce(var.elb_5xx_message, var.message)}" query = < ${var.elb_5xx_threshold_critical} + sum(${var.elb_5xx_timeframe}): + default(avg:aws.elb.httpcode_elb_5xx${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) / ( + default(avg:aws.elb.request_count${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.elb_5xx_threshold_critical} EOF type = "metric alert" @@ -104,12 +100,10 @@ resource "datadog_monitor" "ELB_too_much_4xx_backend" { message = "${coalesce(var.elb_backend_4xx_message, var.message)}" query = < ${var.elb_backend_4xx_threshold_critical} + sum(${var.elb_backend_4xx_timeframe}): + default(avg:aws.elb.httpcode_backend_4xx${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) / ( + default(avg:aws.elb.request_count${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.elb_backend_4xx_threshold_critical} EOF type = "metric alert" @@ -140,12 +134,10 @@ resource "datadog_monitor" "ELB_too_much_5xx_backend" { message = "${coalesce(var.elb_backend_5xx_message, var.message)}" query = < ${var.elb_backend_5xx_threshold_critical} + sum(${var.elb_backend_5xx_timeframe}): + default(avg:aws.elb.httpcode_backend_5xx${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) / ( + default(avg:aws.elb.request_count${module.filter-tags.query_alert} by {region,loadbalancername}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.elb_backend_5xx_threshold_critical} EOF type = "metric alert" @@ -176,9 +168,9 @@ resource "datadog_monitor" "ELB_backend_latency" { message = "${coalesce(var.elb_backend_latency_message, var.message)}" query = < ${var.elb_backend_latency_critical} + ${var.elb_backend_latency_time_aggregator}(${var.elb_backend_latency_timeframe}): + default(avg:aws.elb.latency${module.filter-tags.query_alert} by {region,loadbalancername}, 0) + > ${var.elb_backend_latency_critical} EOF type = "metric alert"