For a comprehensive overview of activities within Amazon ECR and to ensure adherence to security policies, leveraging AWS CloudTrail and Amazon CloudWatch is essential. These two services work together to provide robust monitoring capabilities, helping you track who did what, when, and where within your registry environment.
In this section, you’ll learn how to:
Ensure CloudTrail records ECR activity and sends logs to CloudWatch Logs.
In the CloudTrail dashboard, select “Event history” from the left menu.
Filter events by ECR:
Click on the filter “Attribute”, select “Event source”.
In the field next to it, type ecr.amazonaws.com and press Enter.
Access Log groups in CloudWatch:
In the AWS Console search bar, type CloudWatch and select the CloudWatch service.
In the CloudWatch dashboard, select “Log groups” under “Logs”.
Find the CloudTrail Log group:
In the Log group list, find the Log group that CloudTrail is sending logs to (configured in Step 4).
Click on the name of that Log group to view the log streams.
Monitoring metrics and creating Dashboards
Monitor ECR metrics in CloudWatch Metrics:
In the CloudWatch dashboard, select “Metrics” from the left menu.
In the “All metrics” section, select the namespace “ECR” or “AWS/ECR”.
Choose the ECR metrics you want to view (e.g., RepositorySize, ImageCount).
Create a custom Dashboard for ECR (Optional):
In the CloudWatch dashboard, select “Dashboards”.
Click “Create dashboard”, name it (ex: ECR-Operations-Dashboard), and click “Create dashboard”.
Add widgets.
Select the metric to add.
Select ECR.
Choose your ECR repository.
Select create widget.
By setting up AWS CloudTrail to record ECR events and send them to Amazon CloudWatch Logs, you’ve created a robust monitoring system. Now, you can easily track API activities in ECR, analyze detailed logs using CloudWatch Logs Insights, and visualize key ECR performance metrics through custom CloudWatch Dashboards. This allows you to not only understand who did what and when in your image repositories, but also proactively monitor ECR’s status and performance, thereby enhancing both security and operational efficiency.