How can I simplify the process of monitoring logs on multiple Amazon EC2 instances in OpsWorks Stacks?
Last updated: 2020-04-03
I want to simplify the process of monitoring logs on multiple Amazon Elastic Compute Cloud (Amazon EC2) instances in AWS OpsWorks Stacks.
You can easily monitor logs on multiple Amazon EC2 instances by using Amazon CloudWatch Logs with OpsWorks Stacks. You can enable CloudWatch Logs at the layer level in Linux-based stacks for Chef 11.10 and Chef 12.
Note: If you're using a custom instance profile that isn't created by AWS OpsWorks Stacks, then you must manually attach the AWSOpsWorksCloudWatchLogs policy to your profile. For more information, see Managing IAM Policies.
- Open the OpsWorks Stacks console.
- In the Stack name column, choose the stack that you want to enable with CloudWatch Logs.
- In the navigation pane, choose Layers, and then choose CloudWatch Logs.
Important: To enable CloudWatch Logs, you need an OpsWorks Stacks agent that's compatible with CloudWatch Logs and an IAM policy. You're prompted to upgrade to the latest version of the OpsWorks Stacks agent if your settings don't meet this requirement. If prompted, select the required check boxes, and then choose Upgrade.
- For CloudWatch Logs integration, choose On.
- To stream command logs, for Stream command logs, choose Yes.
- To enable custom logs, for Stream custom logs, enter the full path of the log file.
Note: For example, to collect NGINX error logs, enter /var/log/nginx/error.log for the path.
- Choose Save.
- To view the log streams for OpsWorks Stacks, open the Amazon CloudWatch console, and then choose Logs.
Note: The log streams for OpsWorks Stacks take 1–5 minutes to show up in the CloudWatch console.