Skip to main content

02. Amazon CloudWatch Logs

Amazon CloudWatch Logs provides centralized logging for AWS services and custom applications.

It enables real-time monitoring, search, and retention management of logs from various sources.

FeatureDescription
Centralized LoggingCollects and stores logs from AWS services, EC2 instances, and on-premises servers.
Real-Time MonitoringView logs as they stream for troubleshooting and analysis.
Retention ControlAdjustable log retention periods for cost and compliance management.

🔹 Log Sources

SourceDescription
Elastic BeanstalkCollects application logs automatically.
Amazon ECSGathers container logs.
AWS LambdaCaptures function execution logs.
AWS CloudTrailStreams logs based on defined filters.
Route 53Records DNS query logs.
CloudWatch AgentInstalled on EC2 or on-premises servers to push log files.

🔹 CloudWatch Logs for EC2

  1. By default, EC2 instances do not send logs to CloudWatch.
  2. Install and configure the CloudWatch Logs Agent on EC2.
  3. Ensure IAM permissions allow the instance to publish logs.
  4. This Agent can also be deployed on-premises to centralize external server logs.

🧩 Example Use Cases

  • Centralized log collection from microservices.
  • Monitoring Lambda or ECS application behavior.
  • Auditing CloudTrail activity patterns.
  • Analyzing DNS query logs from Route 53.