feat(cloudwatch): display lambda logs#681
Conversation
Fetches CloudWatch Logs for AWS Lambda invocations using FilterLogEvents paginator and streams log messages into the task logger. Includes unit tests covering log retrieval and logging behavior.
|
Hi @shivamwayal37 👋 Could you check and fix the CI please 🙏 ? |
|
Hi @fdelbrayelle, I wanted to share some context on the recent RetryUtils refactor and Kestra version bump. The original fix you reviewed and approved (commit 6b2b5a2) was intentionally simple (manual polling with bounded retries) and proved stable:
After that approval, I was advised to switch to RetryUtils and bump Kestra from 1.1.0 → 1.2.0. I spent significant time trying to make this work correctly (tests, LocalStack, mocked contexts, VariableRenderer, etc.), but in practice it introduced instability and extra complexity in plugin-aws, especially around tests and CI reliability. At this point, the RetryUtils + version bump path isn’t giving a clean or maintainable result for this plugin, whereas the original implementation you approved was stable and aligned with the existing codebase. Given this, I’m reverting to the original fix (without RetryUtils and without the Kestra version bump), as it delivers the same functionality with lower risk and better stability. Happy to revisit RetryUtils later if plugin-aws is formally aligned with 1.2.x across the board. Thanks again for your earlier review, time and guidance — really appreciate it. |
|
Great to see this merged! Thanks for the support and the thorough reviews @fdelbrayelle. This will make debugging Lambdas much easier for everyone. See you in the next PR! |
|
Thank YOU @shivamwayal37 ;-) ! |
What changes are being made and why?
closes #8978 re-submit of #677
This PR adds support for fetching CloudWatch Logs for AWS Lambda invocations and streaming them directly into the Kestra task logger.
Key changes:
Reusable Log Polling: Introduces a CloudWatchLogs abstraction to query logs via the FilterLogEvents paginator.
Enhanced Observability: Modifies the Invoke task to fetch and log Lambda execution logs, making debugging significantly easier.
Resilient Logic with RetryUtils: Utilizes Kestra's native RetryUtils to handle CloudWatch ingestion latency. This ensures logs are captured even if they aren't immediately available after the invocation.
Project Alignment: Updated kestraVersion to 1.2.0 to support the aforementioned RetryUtils and synced with main to include CI stability fixes from #679.
How the changes have been QAed?
Verified using InvokeUnitTest with mocked CloudWatch responses and tested against a live AWS environment. Streamed logs are prefixed with [lambda] for clarity.
Setup Instructions
Standard AWS credentials are required. The IAM identity must have the following permissions:
Contributor Checklist ✅