Centralized Log Management & Analysis
CloudWatch Logs enables you to centralize the logs from all your systems, applications, and AWS services that you use, in a single, highly scalable service. You can then view them, search them for specific error codes or patterns, filter them based on specific fields, or archive them to long-term storage.
A log event is a record of some activity recorded by the application or resource being monitored. It consists of a timestamp and a raw message.
A log stream is a sequence of log events that share the same source. For example, a log stream could be associated with an EC2 instance or a Lambda function.
Log groups define a group of log streams that share the same retention, monitoring, and access control settings. You can define log retention policies to automatically delete old log events.
You can use metric filters to extract metric observations from ingested events and transform them into data points for a CloudWatch metric. This is a powerful way to generate metrics from application logs (e.g., counting the number of "ERROR" occurrences).
Subscription filters provide access to a real-time feed of log events and can deliver them to other services such as Amazon Kinesis, AWS Lambda, or Amazon OpenSearch Service for custom processing, analysis, or loading to other systems.
CloudWatch Logs can collect logs from a wide variety of sources:
CloudWatch Logs Insights is a powerful interactive query service that enables you to explore, analyze, and visualize your logs. You can run complex queries to efficiently search log data and identify operational issues.
fields @timestamp, @message
| filter @message like /ERROR/
| stats count() as errorCount by bin(5m)
| sort @timestamp desc