Install CloudWatch Agent

Install CloudWatch Agent


  • Each server will run the agent. You need to access to the instance that you want to install CloudWatch Agent
    1. Download the agent package by command:
      sudo wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
      You can refer another agent package at Agent link download
    2. Install package agent by running this command:
      sudo rpm -U ./amazon-cloudwatch-agent.rpm Install CloudWatch Agent
    3. Add a script to JSON file config.json for monitoring memory:
      sudo vi /opt/aws/amazon-cloudwatch-agent/bin/config.json
   {
    "logs": {
        "logs_collected": {
            "files": {
                "collect_list": [
                    {
                        "file_path": "/var/log/httpd/access_log",
                        "log_group_name": "access_log"
                    }
                ]
            }
        }
    },
    "metrics": {
        "metrics_collected": {
            "mem": {
                "measurement": [
                    "mem_used_percent"
                ],
                "metrics_collection_interval": 30
            }
        }
    }
}
  1. Deploy this script to AWS CloudWatch Agent by this 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 Install CloudWatch Agent