https://github.com/sattyagrah/awscloudwatchagent
Install CloudWatch agent (along with its configuration) in EC2 Linux instances.
https://github.com/sattyagrah/awscloudwatchagent
aws-ec2 bash-script cloudwatch cloudwatch-agent cloudwatch-metrics linux linux-shell
Last synced: about 1 month ago
JSON representation
Install CloudWatch agent (along with its configuration) in EC2 Linux instances.
- Host: GitHub
- URL: https://github.com/sattyagrah/awscloudwatchagent
- Owner: sattyagrah
- Created: 2024-08-14T03:10:38.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-30T16:13:50.000Z (8 months ago)
- Last Synced: 2025-04-05T18:16:09.407Z (about 1 month ago)
- Topics: aws-ec2, bash-script, cloudwatch, cloudwatch-agent, cloudwatch-metrics, linux, linux-shell
- Language: Shell
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
## How to use
#### Considerations
> [!IMPORTANT]
>
> + The script is tested on the following architecture and only works on the following OS :
>
> > ```
> > x86_64 (amd64): Amazon Linux 2, Amazon Linux 2023, SLES 12/15, RHEL 8/9, Ubuntu 20/22/24, Debian
> > aarch64 (arm64): Amazon Linux 2, Amazon Linux 2023, SLES 12/15, RHEL 8/9, Ubuntu 20/22/24
> > ```#### Prerequisites
> [!WARNING]
>
> 1. Please make sure that the EC2 instance(s) have **[necessary permission](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent-commandline.html)** attached to it.#### Download the script
```sh
curl "https://raw.githubusercontent.com/sattyagrah/CloudWatchAgent/main/configuration.sh" -o "configuration.sh"
```
and```sh
curl "https://raw.githubusercontent.com/sattyagrah/CloudWatchAgent/main/cwagentinstall.sh" -o "cwagentinstall.sh"
```#### Give executable permission
```sh
chmod u+x cwagentinstall.sh
```#### Execute the script
```sh
./cwagentinstall.sh
```> [!NOTE]
>
> - If users want to change the configuration file of Cloudwatch agent or set the configuration file using wizards, they can do so by following the steps below :
>
> 1. Before executimg *(after downloading)* the **cwagentinstall.sh** file, make sure to comment the line [42](https://github.com/mrsatya21/CloudWatchAgent/blob/main/cwagentinstall.sh#L42) and [43](https://github.com/mrsatya21/CloudWatchAgent/blob/main/cwagentinstall.sh#L43).
>
> 2. Log in to your EC2 instance.
>
> 3. Run the command :
> > ```sh
> > sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
> > ```
>
> 4. Follow the prompt and answer the questions asked and your configuration file will be ready.
>
> 5. After that you need to run the command *(to start the CloudWatch agent)* :
> > ```sh
> > 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
> > ```
>
> 6. Bingo! You are all set now.