From db8777eb0adad230f3446abaa966a348478bdf5a Mon Sep 17 00:00:00 2001 From: larisa17 Date: Mon, 13 May 2024 12:18:38 +0300 Subject: [PATCH 1/4] update 4xx threshold & timeframe --- infra/aws/index.ts | 6 +++--- infra/lib/scorer/loadBalancer.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/infra/aws/index.ts b/infra/aws/index.ts index 2f9776b99..7fd3273d9 100644 --- a/infra/aws/index.ts +++ b/infra/aws/index.ts @@ -87,18 +87,18 @@ const CERAMIC_CACHE_SCORER_ID_CONFG = Object({ }); const alarmConfigurations: AlarmConfigurations = { - percentHTTPCodeELB4XX: 0.1, // 0..1 value for ELB error codes + percentHTTPCodeELB4XX: 0.5, // 0..1 value for ELB error codes percentHTTPCodeELB5XX: 0.01, // 0..1 value for ELB error codes indexerErrorThreshold: 2, // threshold for indexer logged errors indexerErrorPeriod: 1800, // period for indexer logged errors, set to 30 min for now default: { - percentHTTPCodeTarget4XX: 0.1, // 0..1 value for target error codes + percentHTTPCodeTarget4XX: 0.5, // 0..1 value for target error codes percentHTTPCodeTarget5XX: 0.01, // 0..1 value for target error codes targetResponseTime: 2, // seconds }, "passport-analysis-GET-0": { - percentHTTPCodeTarget4XX: 0.1, // 0..1 value for target error codes + percentHTTPCodeTarget4XX: 0.5, // 0..1 value for target error codes percentHTTPCodeTarget5XX: 0.01, // 0..1 value for target error codes targetResponseTime: 20, // 20 seconds - this is a slower request }, diff --git a/infra/lib/scorer/loadBalancer.ts b/infra/lib/scorer/loadBalancer.ts index 780406828..293d4b0e0 100644 --- a/infra/lib/scorer/loadBalancer.ts +++ b/infra/lib/scorer/loadBalancer.ts @@ -98,7 +98,7 @@ export function createLoadBalancerAlarms( LoadBalancer: albArnSuffix, }, namespace: metricNamespace, - period: 60, + period: 900, // 15 minutes stat: "Sum", }, }, @@ -110,7 +110,7 @@ export function createLoadBalancerAlarms( LoadBalancer: albArnSuffix, }, namespace: metricNamespace, - period: 60, + period: 900, // 15 minutes stat: "Sum", }, }, From 7c311a593b617d48127578cf08ee8b33b470d1de Mon Sep 17 00:00:00 2001 From: larisa17 Date: Mon, 13 May 2024 15:34:00 +0300 Subject: [PATCH 2/4] improve error logs --- api/aws_lambdas/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/aws_lambdas/utils.py b/api/aws_lambdas/utils.py index f6b31a317..cfdf86d98 100644 --- a/api/aws_lambdas/utils.py +++ b/api/aws_lambdas/utils.py @@ -110,7 +110,7 @@ def strip_event(event) -> tuple: def parse_body(event): - if event["isBase64Encoded"] and "body" in event and event["body"]: + if event["isBase64Encoded"] and "body" in event and event["body"]: body = json.loads(base64.b64decode(event["body"]).decode("utf-8")) elif "body" in event and event["body"]: body = json.loads(event["body"]) @@ -227,12 +227,15 @@ def wrapper(_event, context): response = { "statusCode": status, + "statusCategory": "4XX" if (status >= 400 and status < 500) else "5XX", "statusDescription": str(e), "isBase64Encoded": False, "headers": RESPONSE_HEADERS, "body": '{"error": "' + message + '"}', } + logger.exception(f"Response: {response}") + # Log analytics for the API call try: if api_key_id: From 3153c3dfbc60af30345c3f5c41b80c14bc3212a6 Mon Sep 17 00:00:00 2001 From: larisa17 Date: Mon, 13 May 2024 22:45:45 +0300 Subject: [PATCH 3/4] update error logs --- api/aws_lambdas/utils.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/api/aws_lambdas/utils.py b/api/aws_lambdas/utils.py index cfdf86d98..6299e4772 100644 --- a/api/aws_lambdas/utils.py +++ b/api/aws_lambdas/utils.py @@ -154,15 +154,15 @@ def wrapper(event, context, *args): type(e), (400, "An error has occurred") ) - logger.exception(f"Error occurred with Passport API: {e}") - - return { + response = { "statusCode": status, "statusDescription": str(e), "isBase64Encoded": False, "headers": RESPONSE_HEADERS, "body": '{"error": "' + message + '"}', } + logger.exception("Error occurred with Passport API. Response: %s", json.dumps(response)) + return response return wrapper @@ -223,8 +223,6 @@ def wrapper(_event, context): type(e), (500, "An error has occurred") ) - logger.exception(f"Error occurred with Passport API: {e}") - response = { "statusCode": status, "statusCategory": "4XX" if (status >= 400 and status < 500) else "5XX", @@ -233,8 +231,7 @@ def wrapper(_event, context): "headers": RESPONSE_HEADERS, "body": '{"error": "' + message + '"}', } - - logger.exception(f"Response: {response}") + logger.exception("Error occurred with Passport API. Response: %s", json.dumps(response)) # Log analytics for the API call try: From c264082d404d672d9116dc9f2e5c083afbf98ec4 Mon Sep 17 00:00:00 2001 From: larisa17 Date: Tue, 14 May 2024 16:53:06 +0300 Subject: [PATCH 4/4] add StatusCategory --- api/aws_lambdas/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/aws_lambdas/utils.py b/api/aws_lambdas/utils.py index 6299e4772..ecaa1c0f1 100644 --- a/api/aws_lambdas/utils.py +++ b/api/aws_lambdas/utils.py @@ -156,11 +156,13 @@ def wrapper(event, context, *args): response = { "statusCode": status, + "statusCategory": "4XX" if (status >= 400 and status < 500) else "5XX", "statusDescription": str(e), "isBase64Encoded": False, "headers": RESPONSE_HEADERS, "body": '{"error": "' + message + '"}', } + logger.exception("Error occurred with Passport API. Response: %s", json.dumps(response)) return response