
- #LOGS ON AWS INSTALL#
- #LOGS ON AWS DOWNLOAD#
I have explained the Cloudwatch logs agent setup to push application logs to the Cloudwatch logging service. You can use the cloud watch filter option to filter and query required logs.
If you click the instance identifier, it shows all the logs. Select the log group and you should see your instance identified you mentioned in the config. Go to Logs –> Log Groups and you will see the log group you mentioned in the agent configuration. Once the setup is done, you can view all the configured logs under the cloudwatch dashboard (under the logs option)
Validating Custom Logs in Cloudwatch Dashboard sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status You can check the agent status using the following command.
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json -s Now, let’s start the Cloudwatch agent using the following. Here is the final cloudwatch agent config. Or you can use you can replace the log locations with your applcation log path.
#LOGS ON AWS INSTALL#
Note: Install Nginx, if you want to follow the following configs for testing purposes. Nginx error logs from /var/log/nginx/error.log.Nginx access logs from /var/log/nginx/access.log.In my case, I am going to replace the default config.json with a custom config.json that collects the following logs. The final config files get stored in the following location/ /opt/aws/amazon-cloudwatch-agent/bin/config.json It prompts you with all the agent-related questions.įor the question, Do you want to store the config in the SSM parameter store?, select No. If you are just starting with a cloud watch agent, it is better to run the cloud watch agent wizard that helps you create the log agent configurations. Here is the tree structure of the files present in the directory. Rpm -U amazon-cloudwatch-agent.rpm Configure Cloudwatch AgentĪfter the installation, you can find all the cloudwatch agent-related config files and executables in the following location. I am downloading the latest Ubuntu package and installing it.
#LOGS ON AWS DOWNLOAD#
Step 2: Download the appropriate agent installation file. You can select regions wise package as well. Step 1: Head over to the Cloudwatch agent downloads page. SSH into the ec2 instance and follow the steps given below.
Select the custom cloud watch IAM role from the dropdown and save it. Right-click for options and select Security and then choose Modify IAM Role option. Head over to ec2 and select the instance in which you want to configure the custom logs. Step 1: Head over to AWS IAM –> Policies–> Create PolicyĪWS ARN Explained: Amazon Resource Name Guideįollow the steps given below to add the custom IAM role to the ec2 instance where you want to set up the cloud watch agent. This IAM role will have policies with write access to the Cloudwatch service so that all the logs from ec2 instances can be shipped to Cloudwatch.īefore creating a role, you need to create a custom policy. To set up AWS custom logs, first, you need to create and add a custom ec2 IAM role to your instance. Note: In an actual project implemention the cloudwatch ec2 agent and configuration would be part of the AMI (Golden Image) or AMI packaging tool like packer. Start the agent with the configuration file. Configure log sources in the Cloudwatch agent configuration file. Create a custom ec2 IAM role with Cloudwatch log write access. All you need to have is a Cloudwatch agent running on your instance. You can send logs from any number of ec2 sources to Cloudwatch. Ec2 instance metrics/custom system metrics/ app metrics can be pushed to cloudwatch.Īpplication Logs To AWS Cloudwatch Workflow. Custom application logs (java, python, etc) can be pushed to cloudwatch and you can setup custom dashbaords and alerts based on log patterns. Web server (Nginx, Apache etc ) access or error logs can be pushed to Cloudwatch logs it acts as central log management for your applications running on AWS. Here are some example use cases for custom logs and metrics Add the Cloudwatch Role to the InstanceĪWS Cloudwatch logs service has the capability to store custom logs and process metrics generated from your application instances. Create an IAM role for Cloudwatch Agent. Application Logs To AWS Cloudwatch Workflow.