Setting up the CloudWatch agent
In Chapter 8, Monitoring AWS Services Using CloudWatch and SNS, we learned how to set up the CloudWatch agent to push custom metrics—for example, memory and disk statistics—to CloudWatch. In this chapter, we will extend this concept further and use the CloudWatch agent to push system logs—for example /var/log/messages
and /var/log/secure
—to CloudWatch Logs.
Before setting up the CloudWatch agent, we need to understand what a CloudWatch log is. If you want all your logs at one centralized place, then you need to enable CloudWatch Logs. CloudWatch Logs enables you to store and access your log files from EC2, Route53, CloudTrail, and other sources at one centralized location. You can use them to search for a specific code, filter them based on specific fields, and archive them for future analysis. Before setting up the CloudWatch agent, we first need to set up CloudWatch Logs. These are the steps we need to follow:
-
...