From 6b21bf4f7b6ababfdc4eb388ab4e916e234bf294 Mon Sep 17 00:00:00 2001 From: Quentin Manfroi Date: Mon, 17 Sep 2018 16:36:51 +0200 Subject: [PATCH] MON-304 refactor errors queries for api gateway --- cloud/aws/apigateway/monitors-api.tf | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/cloud/aws/apigateway/monitors-api.tf b/cloud/aws/apigateway/monitors-api.tf index f3c653b..0b1c408 100644 --- a/cloud/aws/apigateway/monitors-api.tf +++ b/cloud/aws/apigateway/monitors-api.tf @@ -7,7 +7,7 @@ resource "datadog_monitor" "API_Gateway_latency" { query = < ${var.latency_threshold_critical} EOF @@ -38,12 +38,10 @@ resource "datadog_monitor" "API_http_5xx_errors_count" { message = "${coalesce(var.http_5xx_requests_message, var.message)}" query = < ${var.http_5xx_requests_threshold_critical} + sum(${var.http_5xx_requests_timeframe}): + default(avg:aws.apigateway.5xxerror{${var.filter_tags}} by {region,apiname,stage}.as_count(), 0) / ( + default(avg:aws.apigateway.count{${var.filter_tags}} by {region,apiname,stage}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.http_5xx_requests_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}" @@ -73,12 +71,10 @@ resource "datadog_monitor" "API_http_4xx_errors_count" { message = "${coalesce(var.http_4xx_requests_message, var.message)}" query = < ${var.http_4xx_requests_threshold_critical} + sum(${var.http_4xx_requests_timeframe}): + default(avg:aws.apigateway.4xxerror{${var.filter_tags}} by {region,apiname,stage}.as_count(), 0) / ( + default(avg:aws.apigateway.count{${var.filter_tags}} by {region,apiname,stage}.as_count(), 0) + ${var.artificial_requests_count}), + * 100 > ${var.http_4xx_requests_threshold_critical} EOF evaluation_delay = "${var.evaluation_delay}"