Hi! you can either export logs to S3 via the log export feature:
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/S3ExportTasksConsole.html 1
You can also query the logs via SDK, for example CloudWatchLogs — Boto3 Docs 1.20.23 documentation 2