Follow one request through a serverless stack: every lambda it invoked, every batch job it submitted, the whole tree with durations, memory and errors per node:
$ track-request /aws/lambda/api-prod 8f6e1b
/aws/lambda/api-prod 8f6e1b (1.24s, 134/512 MB, 210 lines, 0 errors, 2 subrequests)
/aws/lambda/process-order 2a9c7d (0.98s, 201/512 MB, 118 lines, 0 errors, 1 subrequests)
/aws/batch/job/default/7f3e5a (12.40s, ?/2048 MB, 55 lines, 0 errors, 0 subrequests)
/aws/lambda/send-email 91dd02 (0.31s, 84/512 MB, 12 lines, 0 errors, 0 subrequests)
Queries cloudwatch insights for the request logs, finds lambda invocations and batch submissions in the aws sdk debug lines, fetches those too, recurses.
usage: track-request [-h] [-v] [-f FORMAT] [-o OUTPUT] [-d DAYS]
[-l LIMIT] [-m MAXDEPTH]
log_group_name request_id
-f FORMAT- row template; the default shows group, id, duration, memory, lines, errors and subrequest count-o OUTPUT- also write the full logs to a file; a name ending in.gzcompresses, the prefixlog-group:splits output into one file per log group-d DAYS- how far back to search: a number of days, orstart|endtimestamps-l LIMIT- stop after this many log lines per request-m MAXDEPTH- traversal depth, 0 for unlimited
A python package with a single dependency, botocore, on python 3.10 or newer:
uv tool install git+https://github.com/paunovic/track-request.git
or plain pip:
pip install git+https://github.com/paunovic/track-request.git
credentials come from the ambient aws chain - environment variables, profiles, etc.