Is cloudwatch configured and installed on Amazon Linux 2023

0

Is cloudwatch already configured and installed on when creating an EC2 with Amazon Linux 2023?

Where are the config files? And is syslog /var/log/messages already configured? So that I could look at it in cloudwatch after creating the EC2 with Amazon Linux 2023?

asked 6 months ago1102 views
1 Answer
0

Hello.

To output logs to CloudWatch Logs, you need to install CloudWatch Agent.
CloudWatch Agent is not installed by default, so you must install it yourself.
You can install it by following the steps in the document below.
Also, to output logs to CloudWatch, you need to set up an IAM role on EC2, so please set it up using the steps in the document below.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-commandline-fleet.html

profile picture
EXPERT
answered 6 months ago
profile pictureAWS
EXPERT
reviewed 6 months ago
  • Thank you, for the Amazon Linux 2023, it does look like the cloudwatch agent is installed, which is listed in this doc https://docs.aws.amazon.com/linux/al2023/release-notes/all-packages-AL2023.2.html

  • The documentation you shared only indicates that the CloudWatch Agent is included in the package. That is, you need to run the dnf install command to install the CloudWatch Agent. https://repost.aws/knowledge-center/cloudwatch-push-metrics-unified-agent

    sudo dnf install amazon-cloudwatch-agent -y
    
  • By the way, Amazon Linxu2023 does not output "/var/log/messages" by default, so you need to install "rsyslog" with the following command.

    sudo dnf -y install rsyslog
    sudo systemctl enable rsyslog
    sudo systemctl restart rsyslog
    

    An example configuration for CloudWatch Agent is as follows.

    {
    	"agent": {
    		"run_as_user": "root"
    	},
    	"logs": {
    		"logs_collected": {
    			"files": {
    				"collect_list": [
    					{
    						"file_path": "/var/log/messages",
    						"log_group_name": "AmazonLinux2023",
    						"log_stream_name": "{instance_id}"
    					}
    				]
    			}
    		}
    	}
    }
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions