How to Use CloudWatch Logs Insights to Analyze Logs

2021/03/051 min read
bookmark this
Responsive image

Table of Contents

  1. Introduction
  2. CloudWatch Insights Example
  3. Conclusion

Introduction

Here, I provide examples of how to use CloudWatch Insights to search or analyze log data in CloudWatch logs. You can query one log group or multiple logs together to analyze the data. You can also save the query and save the result to the CloudWatch dashboard.

CloudWatch Insights Example

The following is an example of a CloudWatch Insight query. It filters by the logStream name and where the s field is "E".

This is one of the examples I'm trying to get results for MongoDB server error type logs.

filter @logStream = 'i-01beaaff1a6050989' and s = "E"
 | fields @timestamp, @message, s

Conclusion

CloudWatch Logs Insights is a powerful tool for searching and analyzing log data across your AWS environment. You can build complex queries to filter, aggregate, and visualize your log data directly from the CloudWatch console.