Interview Prep/Monitoring & Observability/Kubernetes Monitoring, Scale & Cloud

What are CloudWatch Logs and Logs Insights?

BeginnerConceptKubernetes Monitoring, Scale & Cloud
Answer

CloudWatch Logs stores logs in log groups (per app or service) made of log streams (per instance, container or Lambda execution environment). Retention is set per log group (default is never expire, a common cost trap).

Logs Insights is the query language:

fields @timestamp, @message, @logStream
| filter @message like /ERROR/
| stats count(*) as errors by bin(5m)
| sort errors desc

Other features: metric filters (turn a log pattern into a CloudWatch metric you can alarm on), subscription filters (stream to Lambda, Kinesis or Firehose for shipping to another backend) and the Infrequent Access log class for cheaper storage of rarely queried logs.

aws logs put-retention-policy --log-group-name /app/api --retention-in-days 30
All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Kubernetes Monitoring, Scale & Cloud