Want to know magic of AWS CloudWatch ?

Are you guys using AWS services ?

  • If not then try it once AWS services, it has amazing things which bind each other by ARN. What is AWS CloudWatch ?
  • If yes then have you seen magic behind CloudWatch ? Have you heard about CloudWatch ?

What is CloudWatch ?

As the name says It’s to keep watch on each and every resource of AWS and keep listening and dumping in the form of log data. And it’s available to read or analyze in terms of metrics. This data can be used as an alert mechanism for creating failure or latency mechanisms.

Sample look of CloudWatch log trails :

What magic CloudWatch has(Features): ?

  • Query Your Log Data
  • Monitor Logs from Amazon EC2 Instances
  • Monitor AWS CloudTrail Logged Events
  • Log Retention
  • Archive Log Data
  • Log Route 53 DNS Queries
  • Event Rule ( Scheduler or Cron Job )

How to enabled ?

If you are unable to get CloudWatch log in, the trial check service has the right permission to execute the role to dump logs into CloudWatch or not. Some services will have by default log enable. Example : For dumping Lambda log, execution role required to have permission to CloudWatch.

Go to Lambda -> Permission -> Select Role -> Edit Role -> Edit policy -> Add CloudWatch access policy

How to filter ?

  1. Go to CloudWatch -> CloudWatch Logs -> Log groups
  2. Select or type service which would like to see log
  3. Example want to see API gateway log then search string will be “/aws/apigateway”

How to search string or specific criteria ?

CloudWatch can write custom queries. Go to Insight -> Select Log group -> write query. Select the field which you would like to show on insight and arrange in order by field. Query syntax is here.

Available fields -

Sample Query can find inside insight right panel -

Example of execution log of Lambda -

Use as cronjob or scheduler :

For setting schedule follow below path.

Go to Event -> Create Rule -> Either select Event pattern or Schedule -> Select Service

When set schedule then can add cron job expression or use predefined timing. The target can set input for lambda or other resources.

Note : This article is just a high level overview to know about CloudWatch.

Thanks for reading. If any feedback feel free to reach out to me.

References :

Originally published at https://www.internetkatta.com.

Enthusiastic learner, Full Stack Developer, Techno Savvy, Traveller, Out of Box thinker, Agile Lover, Problem Solver, Blogger