What You Need to Know About CloudWatch Logs 

How many times have you found yourself wondering, What’s going on with my AWS-hosted services? Without the right monitoring tools in place, it can be difficult to get a clear answer. Fortunately, Amazon Web Services has created an extensive toolset called CloudWatch Logs that enables you to both track and analyze all the information associated with your cloud-hosted services, all without having to leave your command line. 

A few things you need to know about cloudwatch logs 

1. They are free, of course 2. They are automatically archived and stored for you, which is an essential feature if you don’t have your own hardware 3. You can access them from anywhere now, because my job sometimes has me monitoring servers that are not physically in a location that I frequent regularly 4. The aws cli tool makes it very easy to interact with cloudwatch logs 5. The aws cli tool can even be run from another instance 6. The AWS SDK (dynamodb) allows you to call cloudwatch directly from your application 7. If something goes wrong with your S3 bucket, AWS will send you an email informing you of it 8. 

How does log data get into cloudwatch? 

First, AWS Agent Manager or some other software agent running on your host submits data logs to CloudWatch Logs. To enable your application agents to send data to CloudWatch Logs, use either: AWS Command Line Interface (AWS CLI) Use configure set-log-stream in configuring logs for an instance using Amazon EC2 Run Command. For information about configuring log streams using AWS CLI and Amazon EC2 Run Command, see Setting Up Application Logging with Amazon EC2 Run Command in Configuring Your Infrastructure for Amazon S3 & Glacier Data Retrieval Using Amazon S3 Lifecycle Configuration of a Host Instance. 

Why use cloudwatch logs? 

The aws cli for cloudwatch logs will enable you to monitor your logs using a service that is provided by Amazon. This means that you can have a centralized logging system so that you have your data in one place and don’t have to keep looking in multiple different places for data. With cloudwatch, you are able to look at historical data as well as do near real-time monitoring of your log files. It also allows you to configure alarms on different metrics and get notified about them via email or SMS. Alarms could be things like: disk space usage reaching over 80% or number of failed login attempts exceeding 50 within 15 minutes. If something happens that requires immediate attention, it is important to be able to notice right away. 

How do I set up my first log group? 

To set up your first log group, open a terminal window and run aws cloudwatch create-log-group. This command takes two arguments: a name for your log group and a description of what kind of logs it will collect. For example, you could use aws cloudwatch create-log-group Production logs. Then, you can tail (or grep ) your new log stream by running aws cloudwatch logs get-log-events log-group-name production. This should output all events in your production.txt file. You can even send these logs into AWS Elasticsearch Service with Kibana! 

SNS Subscriptions For Events in Real Time 

The Amazon Web Services Command Line Interface (AWS CLI) can be used for managing logs from an AWS account. The AWS CLI provides a consistent way of accessing all of your AWS services from your command line. It works with every service that has a supported command-line interface, including Amazon Simple Storage Service (Amazon S3), EC2, Amazon Redshift, and more. To subscribe to an event stream in real time using the AWS CLI, use these steps: First open or refresh an existing log group that you want to monitor for new events.