0% found this document useful (0 votes)
62 views10 pages

Install AWS Systems Manager Agent

The document provides instructions for installing and configuring the Amazon CloudWatch agent on an EC2 instance using AWS Systems Manager (SSM). It describes downloading and installing the agent package, creating an IAM role for SSM, configuring the agent to monitor metrics, and using SSM Run Commands to install and start the agent.

Uploaded by

Rajapriya M
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views10 pages

Install AWS Systems Manager Agent

The document provides instructions for installing and configuring the Amazon CloudWatch agent on an EC2 instance using AWS Systems Manager (SSM). It describes downloading and installing the agent package, creating an IAM role for SSM, configuring the agent to monitor metrics, and using SSM Run Commands to install and start the agent.

Uploaded by

Rajapriya M
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Install System Manager Agent using User data:

#!/bin/bash
cd /tmp
sudo dnf install -y [Link]
windows/SSMAgent/latest/linux_amd64/[Link]
sudo systemctl enable amazon-ssm-agent
sudo systemctl start amazon-ssm-agent
cd /etc/amazon/ssm/
touch [Link]
cp [Link] [Link]
sudo systemctl restart amazon-ssm-agent

yum info amazon-ssm-agent -> To check the ssm services

#!/bin/bash
cd /tmp
wget [Link]
[Link]

sudo dnf install -y [Link]


agent/redhat/amd64/latest/[Link]
cd ..

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m


ec2 -s -c file:etc/opt/aws/amazon-cloudwatch-agent/bin/[Link]

#!/bin/bash
cd /tmp
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m
ec2 -c file:/opt/aws/amazon-cloudwatch-agent/bin/[Link] –s
cd ..
cat <<EOT >> /opt/aws/amazon-cloudwatch-agent/bin/[Link]
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "cwagent"
},
"metrics": {
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"cpu": {
"measurement": [
"cpu_usage_idle",
"cpu_usage_iowait",
"cpu_usage_user",
"cpu_usage_system"
],
"metrics_collection_interval": 60,
"resources": [
"*"
],
"totalcpu": false
},
"disk": {
"measurement": [
"used_percent",
"inodes_free"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"diskio": {
"measurement": [
"io_time"
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
},
"swap": {
"measurement": [
"swap_used_percent"
],
"metrics_collection_interval": 60
}
}
}
}
EOT
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config –m
ec2 -s -c file:etc/opt/aws/amazon-cloudwatch-agent/bin/[Link]

Attach a Role with SSMServiceRole

Open the Systems Manager console at [Link]


In the navigation pane, choose Run Command.
Choose Run command.
In the Command document list, choose AWS-ConfigureAWSPackage.
In the Targets area, choose the instance to install the CloudWatch agent on
In the Action list, choose Install.
In the Name field, enter AmazonCloudWatchAgent.
Keep Version set to latest to install the latest version of the agent.
Choose Run.

To start the CloudWatch agent using Run Command

1. Open the Systems Manager console at [Link]


manager/.
2. In the navigation pane, choose Run Command.
-or-

If the AWS Systems Manager home page opens, scroll down and choose Explore Run
Command.
3. Choose Run command.
4. In the Command document list, choose AmazonCloudWatch-ManageAgent.
5. In the Targets area, choose the instance where you installed the CloudWatch agent.
6. In the Action list, choose configure.
7. In the Optional Configuration Source list, choose ssm.
8. In the Optional Configuration Location box, enter the name of the agent configuration
file that you created and saved to Systems Manager Parameter Store, as explained in Create the
CloudWatch agent configuration file.
9. In the Optional Restart list, choose yes to start the agent after you have finished these
steps.
10. Choose Run.
11. Optionally, in the Targets and outputs areas, select the button next to an instance name
and choose View output. Systems Manager should show that the agent was successfully started.

References:

Role: [Link]

Agent Installation: [Link]


[Link]

Download agent using SSM:


[Link]
[Link]

Configuration using SSM & Start aganet:

[Link]
[Link]

Configuration: [Link]
[Link]

Manual Installation: [Link]


[Link]

Common questions

Powered by AI

Attaching a role with SSMServiceRole is crucial because it allows AWS Systems Manager (SSM) to securely interact with other AWS services on your behalf. This role provides necessary permissions for operations such as executing commands, managing instances, and collecting system-level information. Without the SSMServiceRole, Systems Manager cannot manage resources effectively, restricting functionalities like installing or starting agents, thereby affecting monitoring and management capabilities . The role ensures that SSM can access and configure instances accurately, maintaining the integrity and security of operations .

To configure the CloudWatch agent for specific system metrics, create a configuration file under '/opt/aws/amazon-cloudwatch-agent/bin/config.json'. This file should specify metrics such as CPU usage, disk usage, memory usage, and swap usage. The configuration also includes parameters to collect these metrics every 60 seconds and to append dimensions for 'AutoScalingGroupName', 'ImageId', 'InstanceId', and 'InstanceType' . After setting the 'metrics_collected' object with the appropriate 'measurement' fields for each resource type like 'cpu', 'disk', 'diskio', 'mem', and 'swap', apply the configuration using the command 'sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json'. This setup enables the agent to capture and forward specified system metrics to CloudWatch .

Systems Manager Parameter Store offers several benefits for storing CloudWatch agent configuration files, enhancing both operational efficiency and security. It provides a centralized repository for configuration data, enabling easy access and management across multiple instances. Parameter Store also supports versioning, which allows tracking of configuration changes over time and easy reversion if needed . Moreover, it supports IAM, providing granular control over access to parameters and thereby enhancing security. The integration with AWS Systems Manager further automates the deployment and management of configurations, reducing manual errors and ensuring consistency across environments . These features collectively streamline configuration management and improve the reliability of monitored systems.

Using a pre-configured JSON file for CloudWatch agent setup involves several key steps. First, ensure that the JSON configuration file reflects the monitoring needs, specifying metrics and their collection intervals precisely. Place this file at a path accessible to the system, typically '/opt/aws/amazon-cloudwatch-agent/bin/config.json'. The configuration could include various system metrics such as CPU, memory, and disk usage. Once the JSON is set up, use the command 'sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/path/to/config.json' where '-c file' specifies the path to the JSON configuration. This command fetches and applies the configuration, initiating the CloudWatch agent to collect and report metrics based on the defined settings . This process leverages predefined configurations to ensure consistent setup across multiple instances, enhancing monitoring efficacy .

Automatically restarting the CloudWatch agent after configuration through AWS Systems Manager is significant because it ensures that new settings are immediately applied without requiring manual intervention. This practice enhances configuration reliability, allowing systems to start monitoring with the updated parameters right away . An immediate restart helps in quickly recognizing issues with the new configuration and ensures there is no delay in metric collection, which could be critical for applications with stringent monitoring requirements . Additionally, automating the restart reduces operations overhead and minimizes potential human error in restarting services.

To start the CloudWatch agent using AWS Systems Manager's Run Command, first, open the Systems Manager console. Navigate to the 'Run Command' option and choose 'Run command'. Select 'AmazonCloudWatch-ManageAgent' from the Command document list. In the Targets area, select the instance where the CloudWatch agent is installed. Choose 'configure' under the Action list, set the Configuration Source to 'ssm', and specify the name of your configuration file stored in Systems Manager Parameter Store . Optionally set the configuration to restart the agent by selecting 'yes' under the Optional Restart list. Finally, execute the command by choosing 'Run'. The system will confirm the successful start of the agent .

The installation process for the System Manager Agent using user data involves several steps. First, navigate to the /tmp directory using the command 'cd /tmp'. Utilize the 'dnf' package manager to install the agent via the 'sudo dnf install -y' command with the URL 'https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm' . Once installed, enable the agent with 'sudo systemctl enable amazon-ssm-agent', and start it using 'sudo systemctl start amazon-ssm-agent'. Configuration involves creating the 'amazon.ssm.agent.json' file in '/etc/amazon/ssm/' and copying the template configuration file into it. Finally, restart the agent to apply changes using 'sudo systemctl restart amazon-ssm-agent'. You can check the status and information of SSM services via 'yum info amazon-ssm-agent' .

Specifying 'metrics_collection_interval' in the CloudWatch agent configuration directly influences how frequently the agent collects and forwards data from the monitored instance to CloudWatch. Setting this interval determines the granularity and timeliness of the metrics captured, allowing users to balance between data accuracy and resource utilization. For example, a lower interval like 60 seconds enables near real-time monitoring but at the cost of higher resource consumption. Conversely, increasing this interval can reduce the load on instance resources but might result in less timely data, which may not be suitable for scenarios requiring immediate response or detailed trend analysis . Adjusting this parameter accordingly can help optimize performance while ensuring critical service insights are captured .

Installing the CloudWatch agent on a Red Hat Linux system may pose a few challenges, primarily related to package management and dependencies. Compatibility issues can arise since the agent requires certain RPM packages that may conflict with existing system libraries. This can be mitigated by ensuring the system is updated and compatible with the agent's packages. Issues with permissions and roles might necessitate correct IAM role attachment to allow the agent to function properly . Mitigation involves verifying roles and permissions via the AWS console to confirm they include the requisite policies. Another challenge could be network access restrictions impacting download and configuration processes, resolvable by configuring appropriate VPC endpoints and security rules . Proper planning and pre-checks can significantly reduce these installation hurdles.

Using 'AmazonCloudWatchAgent' as the name when setting up the CloudWatch agent configuration in AWS Systems Manager is significant because it standardizes the installation process and helps in identifying the agent package within the Systems Manager console. When the command 'Run' is issued and the name is specified, it matches the agent with its configuration scripts and ensures that the correct version of the CloudWatch agent is installed and managed appropriately on instances. This naming consistency also aids in automating repeating tasks and minimizing conflicts or errors during agent setup .

You might also like