Implement EMF and Container Insights log cleanup (#147) #613
+736
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses issue #147 by implementing comprehensive cleanup functionality for EMF (Embedded Metric Format) and Container Insights logs that persist after test execution.
Changes Made
1. New Log Cleanup Utility (
util/awsservice/log_cleanup.go)2. Test Framework Integration
CleanupAfterTest()method to interface and default implementation3. Environment Variable Controls
CWAGENT_SKIP_LOG_CLEANUP: Completely disable cleanup (useful for debugging)CWAGENT_FORCE_LOG_CLEANUP: Enable actual deletion (defaults to dry-run for safety)4. Comprehensive Documentation (
docs/log-cleanup.md)Log Group Patterns Addressed
Container Insights:
/aws/ecs/containerinsights/*/performance/aws/ecs/containerinsights/*/application/aws/eks/containerinsights/*/performance/aws/eks/containerinsights/*/applicationEMF Logs:
EMFECSNameSpace/EMFEKSNameSpace(from test configurations)*EMF*and*emf*patterns/aws/lambda/*(Lambda EMF logs)ECS Task Logs:
/ecs/*and/aws/ecs/*Test-specific:
*test*,cwagent-*, etc.Safety Features
Usage Examples
Default Behavior (Dry-Run)
Enable Actual Cleanup
Disable for Debugging
Integration Points
Benefits
Backward Compatibility
CleanupAfterTest()method added toITestRunnerinterfaceTesting
The implementation has been tested with:
Files Changed
util/awsservice/log_cleanup.go- New cleanup utilitytest/test_runner/base_test_runner.go- Interface and default cleanuptest/test_runner/ecs_test_runner.go- ECS-specific cleanup integrationtest/emf/emf_container_test.go- EMF-specific cleanup implementationdocs/log-cleanup.md- Comprehensive documentationResolves #147
This implementation provides a robust, safe, and automated solution for cleaning up EMF and Container Insights logs while maintaining backward compatibility and providing extensive safety measures.