PART 1: SET UP LOG RETENTION SETTING
Financial safety note (Cost Guardrails): AWS defaults to storing logs indefinitely (Never Expire), which will increase the Account’s storage costs. The documentation requires you to bring it down to 7 days.
Execute the following steps sequentially for all 6 group names:
In the AWS Console search bar at the top, type CloudWatch ➔ Select the CloudWatch service.

On the left sidebar menu, find the Logs section ➔ Click Log groups.
Looking at the right corner of the screen, click the Create log group button.
Detailed configuration:
/aws/lambda/docuflow-dev-ai-proxy-lambdaalias/docuflow-dev-main-key if you want to encrypt logs according to the highest security standards).

Click the Create button at the bottom.

Repeat the exact steps above for the remaining 5 names:
/aws/lambda/docuflow-dev-ingestion-job-starter-lambda/aws/lambda/docuflow-dev-api-generate-upload-url-lambda/aws/lambda/docuflow-dev-ai-textract-lambda/aws/lambda/docuflow-dev-ai-confidence-status-lambda/aws/lambda/docuflow-dev-data-lambdaPART 2: CREATE METRIC FILTERS TO MONITOR IMPORTANT METRICS (CUSTOM METRICS)
To serve the Workshop/Demo for displaying visual charts, you need to extract metrics from Logs into Metrics. We will make 2 core filter sets:
Filter Set 1: Catch system errors errorType (Configured on Tai’s AI Proxy function)
This filter helps count the number of times the AI Proxy function fails when calling an external LLM or due to a code error.
/aws/lambda/docuflow-dev-ai-proxy-lambda.
Step 1: Define pattern (Define search keyword):
"errorType" (including the 2 quotes to correctly scan standard JSON error log structures).
Step 2: Assign metric (Assign system metric):
docuflow-dev-proxy-error-filterDocuFlowAI/Metrics (Written together, this is the master box to contain all custom metrics of the project).ProxyExecutionErrors1 (Meaning every time a log line appears with the word "errorType", the system automatically increments the count by 1).
Step 3: Review and create:

Filter Set 2: Monitor the number of invoices requiring manual review REVIEW_REQUIRED (Configured on Tra’s function)
This filter helps count how many invoices have a low confidence score and need human intervention to review.
/aws/lambda/docuflow-dev-ai-confidence-status-lambda.Step 1: Define pattern:
"REVIEW_REQUIRED". Click Next.

Step 2: Assign metric:
docuflow-dev-review-required-filterDocuFlowAI/MetricsInvoicesRequiringHumanReview1. Click Next.

Step 3: Review and create:
Click Create metric filter to finish.

