aws-observability / observability-best-practices

Observability best practices on AWS
https://aws-observability.github.io/observability-best-practices/
MIT No Attribution
224 stars 69 forks source link

CloudWatch Logs Insights Example Query - Amazon RDS/Aurora #17

Closed kiranprakash-aws closed 11 months ago

kiranprakash-aws commented 1 year ago

Aurora PostgresQL cluster log

Filtering logs that have ERROR messages in them

fields @timestamp, @message, @logStream, @log
| filter @message like "ERROR"
| sort @timestamp desc

Filtering logs that have ERROR messages and aggregating them for a required time window like 1 hour

fields @timestamp, @message, @logStream, @log
| filter @message like "ERROR"
| stats count(*) as errCount by bin(1h)

Filtering logs that have specific texts in the message field

fields @timestamp, @message, @logStream, @log
| filter @message like 'could not receive data from client: Connection reset by peer'
| sort @timestamp desc

Amazon RDS Error log - MySQL

Filtering logs that have Warning messages in them

fields @timestamp, @message, @logStream, @log
| filter @message like "Warning"
| sort @timestamp desc

MySQL Error Codes - https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference.html Getting the logs based on the specific mySQL error codes

fields @timestamp, @message, @logStream, @log
| filter @message like 'MY-010055'
| sort @timestamp desc
kiranprakash-aws commented 11 months ago

inactivity