FAUN — Developer Community 🐾

We help developers learn and grow by keeping them up with what matters. 👉 www.faun.dev

Follow publication

Member-only story

Store Rails Logs on Amazon CloudWatch Logs (EC2 Docker)

--

CloudWatch Logs

You can store your logs on the application itself, but this can take up quite a lot of storage on your volume after a while. It can also be quite a hassle to have to monitor the logs as you have to enter your EC2 instance console.

To prevent this, we decided to send logs to Amazon CloudWatch Logs on our applications. This is a cheap way to be able to monitor our logs and it also enables us to set a retention period.

Setup a CloudWatch Logs IAM Policy and IAM Role

Before your EC2 can send log data to CloudWatch Logs, you have to create an IAM policy and IAM role to allow your EC2 instance to use the CloudWatch Logs APIs.

Create an IAM Policy

  1. Open the IAM console: https://console.aws.amazon.com/iam/
  2. In the navigation pane, choose Policies
  3. Choose Create policy and click on JSON.
  4. Enter the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
]…

--

--

No responses yet

Write a response