From 979aeb96e976b45437878f640a8237b197288a2a Mon Sep 17 00:00:00 2001 From: nutrina Date: Fri, 10 May 2024 11:38:34 +0300 Subject: [PATCH] =?UTF-8?q?fix(infra):=20fix=20proper=20dimension=20value?= =?UTF-8?q?=20for=205xx,=204xx=20and=20response=20time=E2=80=A6=20(#589)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(infra): fix proper dimension value for 5xx, 4xx and response time alarms * fix(infra): fix more alarm dimensions and namespaces * fix(infra): fix namespace in alarm for running count in ECS tasks * fix(infra): fix namespace in alarm for running count in ECS tasks * fix(infra): fix namespace in alarm for memory utilisation * fix(infra): fix evaluation for running task count --- infra/aws/index.ts | 2 +- infra/lib/scorer/loadBalancer.ts | 10 +++---- infra/lib/scorer/new_service.ts | 46 ++++++++++++++++---------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/infra/aws/index.ts b/infra/aws/index.ts index ca616fed0..011470cde 100644 --- a/infra/aws/index.ts +++ b/infra/aws/index.ts @@ -1303,7 +1303,7 @@ const lambdaSettings = { createLoadBalancerAlarms( "scorer-service", - alb.name, + alb.arnSuffix, alarmConfigurations, pagerdutyTopic ); diff --git a/infra/lib/scorer/loadBalancer.ts b/infra/lib/scorer/loadBalancer.ts index 44750f901..662f90637 100644 --- a/infra/lib/scorer/loadBalancer.ts +++ b/infra/lib/scorer/loadBalancer.ts @@ -15,7 +15,7 @@ export type AlarmConfigurations = { export function createLoadBalancerAlarms( name: string, - albName: Input, + albArnSuffix: Input, loadBalancerAlarmThresholds: AlarmConfigurations, alertTopic?: Topic ) { @@ -40,7 +40,7 @@ export function createLoadBalancerAlarms( metric: { metricName: "RequestCount", dimensions: { - LoadBalancer: albName, + LoadBalancer: albArnSuffix, }, namespace: metricNamespace, period: 60, @@ -52,7 +52,7 @@ export function createLoadBalancerAlarms( metric: { metricName: "HTTPCode_ELB_5XX_Count", dimensions: { - LoadBalancer: albName, + LoadBalancer: albArnSuffix, }, namespace: metricNamespace, period: 60, @@ -89,7 +89,7 @@ export function createLoadBalancerAlarms( metric: { metricName: "RequestCount", dimensions: { - LoadBalancer: albName, + LoadBalancer: albArnSuffix, }, namespace: metricNamespace, period: 60, @@ -101,7 +101,7 @@ export function createLoadBalancerAlarms( metric: { metricName: "HTTPCode_ELB_4XX_Count", dimensions: { - LoadBalancer: albName, + LoadBalancer: albArnSuffix, }, namespace: metricNamespace, period: 60, diff --git a/infra/lib/scorer/new_service.ts b/infra/lib/scorer/new_service.ts index d16c394f8..0cec1ea16 100644 --- a/infra/lib/scorer/new_service.ts +++ b/infra/lib/scorer/new_service.ts @@ -388,9 +388,9 @@ export function createScorerECSService( evaluationPeriods: 1, metricName: "RunningTaskCount", name: `RunningTaskCount-${name}`, - namespace: "AWS/ECS", + namespace: "ECS/ContainerInsights", period: 300, - statistic: "Sum", + statistic: "Average", threshold: getAutoScaleMaxCapacity() * 0.75, } ); @@ -412,7 +412,7 @@ export function createScorerECSService( evaluationPeriods: 1, metricName: "MemoryUtilization", name: `MemoryUtilization-${name}`, - namespace: "AWS/ECS", + namespace: "ECS", period: 900, statistic: "Average", threshold: 80, @@ -446,8 +446,8 @@ export function createScorerECSService( metric: { metricName: "RequestCountPerTarget", dimensions: { - LoadBalancer: config.alb.name, - TargetGroup: config.targetGroup.name, + LoadBalancer: config.alb.arnSuffix, + TargetGroup: config.targetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -459,8 +459,8 @@ export function createScorerECSService( metric: { metricName: "HTTPCode_Target_5XX_Count", dimensions: { - LoadBalancer: config.alb.name, - TargetGroup: config.targetGroup.name, + LoadBalancer: config.alb.arnSuffix, + TargetGroup: config.targetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -497,8 +497,8 @@ export function createScorerECSService( metric: { metricName: "RequestCountPerTarget", dimensions: { - LoadBalancer: config.alb.name, - TargetGroup: config.targetGroup.name, + LoadBalancer: config.alb.arnSuffix, + TargetGroup: config.targetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -510,8 +510,8 @@ export function createScorerECSService( metric: { metricName: "HTTPCode_Target_4XX_Count", dimensions: { - LoadBalancer: config.alb.name, - TargetGroup: config.targetGroup.name, + LoadBalancer: config.alb.arnSuffix, + TargetGroup: config.targetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -539,8 +539,8 @@ export function createScorerECSService( comparisonOperator: "GreaterThanThreshold", datapointsToAlarm: 3, dimensions: { - LoadBalancer: config.alb.name, - TargetGroup: config.targetGroup.name, + LoadBalancer: config.alb.arnSuffix, + TargetGroup: config.targetGroup.arnSuffix, }, evaluationPeriods: 5, metricName: "TargetResponseTime", @@ -1208,8 +1208,8 @@ export function buildHttpLambdaFn( metric: { metricName: "RequestCountPerTarget", dimensions: { - LoadBalancer: alb.name, - TargetGroup: lambdaTargetGroup.name, + LoadBalancer: alb.arnSuffix, + TargetGroup: lambdaTargetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -1221,8 +1221,8 @@ export function buildHttpLambdaFn( metric: { metricName: "HTTPCode_Target_5XX_Count", dimensions: { - LoadBalancer: alb.name, - TargetGroup: lambdaTargetGroup.name, + LoadBalancer: alb.arnSuffix, + TargetGroup: lambdaTargetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -1259,8 +1259,8 @@ export function buildHttpLambdaFn( metric: { metricName: "RequestCountPerTarget", dimensions: { - LoadBalancer: alb.name, - TargetGroup: lambdaTargetGroup.name, + LoadBalancer: alb.arnSuffix, + TargetGroup: lambdaTargetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -1272,8 +1272,8 @@ export function buildHttpLambdaFn( metric: { metricName: "HTTPCode_Target_4XX_Count", dimensions: { - LoadBalancer: alb.name, - TargetGroup: lambdaTargetGroup.name, + LoadBalancer: alb.arnSuffix, + TargetGroup: lambdaTargetGroup.arnSuffix, }, namespace: metricNamespace, period: 60, @@ -1301,8 +1301,8 @@ export function buildHttpLambdaFn( comparisonOperator: "GreaterThanThreshold", datapointsToAlarm: 3, dimensions: { - LoadBalancer: alb.name, - TargetGroup: lambdaTargetGroup.name, + LoadBalancer: alb.arnSuffix, + TargetGroup: lambdaTargetGroup.arnSuffix, }, evaluationPeriods: 5, metricName: "TargetResponseTime",