How do you centralize application logs from many EC2 and ECS services?
BeginnerScenarioObservability, Secrets, KMS and CloudFormation
Answer
Situation read → CloudWatch Logs with agents or log drivers, then subscription filters.
What I'd do →
- EC2 uses the CloudWatch agent with
amazon-cloudwatch-agent-ctl -a fetch-config - ECS uses the
awslogsdriver - Set retention:
aws logs put-retention-policy --log-group-name /app/api --retention-in-days 30 - Subscription filter to Kinesis Firehose to S3 for archive
- Query with Logs Insights
Why → Retention defaults to never expire, which is a silent cost.
Interview tip → Always set retention.
More on Observability, Secrets, KMS and CloudFormation
You need to be paged when 5xx errors on the ALB exceed 2 percent for 5 minutes. How?BeginnerCloudWatch costs exploded. Where do you look?IntermediateInvestigate a latency spike across microservices on AWS. What tools do you use?IntermediateAn auditor asks for proof of every configuration change to security groups for 12 months. What do you provide?IntermediateAuto-remediate any security group opened to 0.0.0.0/0 on port 22.AdvancedWhere should application database passwords live and how do they rotate?Intermediate