Operations
Monitoring
Logs:
/aws/lambda/<function>in CloudWatch Logs. Every line carries thetrace_idof its invocation; raiseLOG_LEVELtoDEBUGtemporarily to see more.LOG_DIAGNOSE=trueadds local variables to tracebacks and can leak task arguments: do not leave it on.Response of every invocation: the handler returns the counters (
processed_messages,failed_messages,skipped_messages) and the list of tasks of each kind.Metrics: with
METRICS_ENABLED=truethe runner writes CloudWatch metrics in the Embedded Metric Format (namespaceCeleryCloud, dimensionTask):TaskSucceeded,TaskFailed,TaskRetried,TaskSkipped,TaskDelayed,TaskIgnored,TaskRejectedandTaskDuration(ms). They come from the log line, so they need no IAM permission and no API call (CloudWatch Logs ingestion is billed as usual).Alarms worth creating
Metric
Meaning
SQS
ApproximateNumberOfMessagesVisibleof the queueTasks are waiting: the runner is throttled, failing or too slow
SQS
ApproximateNumberOfMessagesVisibleof the DLQ (> 0)Messages the runner could not handle after
maxReceiveCountattemptsLambda
Errors,Throttles,Duration(near the timeout)Crashes, concurrency limits and tasks about to be killed
TaskFailed/TaskRetried(with metrics enabled)A task that fails or retries more than usual
Troubleshooting
Symptom |
Check |
|---|---|
Client waits forever ( |
Is the event source mapping enabled and pointing to this queue? Is the client writing to the same queue and the runner reading the table the client reads (same table and Region)? |
|
The |
|
The client is not using the |
Stuck in |
The runner died or timed out mid-task. Increase the timeout or fix the task; the client must have a timeout (see Concepts and behaviour). |
Task runs twice |
Visibility timeout shorter than the function timeout, or the result item was
already deleted by TTL (see Result expiration). Without
|
|
Missing permission in the runner role (IAM roles and permissions). |
Messages go to the DLQ |
Read them ( |
Costs
You pay per request and per millisecond, and nothing while the queue is empty:
Lambda invocations (duration x memory), SQS requests, DynamoDB on-demand reads and
writes (a task writes its item twice or three times: STARTED and the final
state), ECR storage and CloudWatch Logs. Set a retention period on the log group
(aws logs put-retention-policy) so logs do not accumulate indefinitely.
Cleanup
aws lambda delete-event-source-mapping --uuid <mapping-uuid> --region $AWS_REGION
aws lambda delete-function --function-name $FUNCTION --region $AWS_REGION
aws ecr delete-repository --repository-name celery-cloud-runner --force --region $AWS_REGION
aws dynamodb delete-table --table-name $TABLE --region $AWS_REGION
aws sqs delete-queue --queue-url $QUEUE_URL --region $AWS_REGION
aws sqs delete-queue --queue-url ${QUEUE_URL}-dlq --region $AWS_REGION
aws iam delete-role-policy --role-name $FUNCTION --policy-name runner-access
aws iam detach-role-policy --role-name $FUNCTION \
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole
aws iam delete-role --role-name $FUNCTION
delete-table and delete-queue destroy data and cannot be undone.