Don’t know how to find the Status of CloudWatch Agent? We can help you.
Here, at Bobcares, we assist our customers with several AWS queries as part of our AWS Support Services.
Today, let us see how to query CloudWatch Agent to find its status.
Status of CloudWatch Agent
Moving ahead, let us discuss different aspects of a CloudWatch Agent.
-
Verify that the CloudWatch agent is running
To do so, we use AWS Systems Manager.
In addition, on the local server, we can use the command line.
- We open the Systems Manager console.
- Then in the navigation pane, we select Run Command.
-or-
If the AWS Systems Manager home page opens, we select Explore Run Command.
- In the Command document list, we select the AmazonCloudWatch-ManageAgent.
- In the Action list, we select status.
- We select the default for Optional Configuration Source.
- We keep Optional Configuration Location blank.
- Then in the Target area, we select the instance to check.
- Finally, we click, Run.
The output will be like this:
{
“status”: “running”,
“starttime”: “2017-12-12T18:41:18”,
“version”: “1.73.4”
}
On the other hand, to query the status locally via the command line our Support Techs suggest:
On a Linux server:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a status
Then on a Windows Server as an administrator, we run:
& $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a status
-
Stop and restart the CloudWatch agent
First, let us stop the agent via Run Command.
- To do so, we open the Systems Manager console
- In the navigation pane, we select the Run Command.
-or-
Like the above, if the home page opens, we select Explore Run Command.
- In the Command document list, we select AmazonCloudWatch-ManageAgent.
- Then in the Targets area, we select the instance with the CloudWatch agent.
- In the Action list, we select stop.
- We keep Optional Configuration Source and Optional Configuration Location blank.
- Later we select, Run.
Now, let us stop it locally via the command line.
On a Linux server:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -m ec2 -a stop
On Windows Server:
& $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a stop
-
Start the CloudWatch agent using Systems Manager Run Command
Our Support Techs recommend the below steps to start the agent via Run Command:
- Open the Systems Manager console.
- Then we select the Run Command in the navigation pane.
-or-
In the case of the AWS Systems Manager home page opens, we select Explore Run Command.
- In the Command document list, we select AmazonCloudWatch-ManageAgent.
- Then we select the instance with the CloudWatch agent in the Targets area.
- In the Action list, select configure.
- Then in the Optional Configuration Source list, select ssm.
- After that, in the Optional Configuration Location box, we enter the name of the agent configuration file that we created and saved.
- In the Optional Restart list, we can select yes.
- Eventually, we click Run.
-
Start the CloudWatch agent on an Amazon EC2 instance using the command line
To do so, our Support Techs recommend the following:
a) Linux and macOS:
If we save the configuration file in the Systems Manager Parameter Store:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c ssm:configuration-parameter-store-name
b) Linux and macOS:
On the other hand, if we save the configuration file on the local computer:
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:configuration-file-path
c) Windows Server:
If we save the agent configuration file in Systems Manager Parameter Store:
& “C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1” -a fetch-config -m ec2 -s -c ssm:configuration-parameter-store-name
d) Windows Server:
Similarly, if we save the agent configuration file on the local computer:
& “C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:configuration-file-path
[Need help with the process? We’d be happy to assist]
Conclusion
In short, we saw how our Support Techs find the status of CloudWatch Agent.
Thankyou very much for this. Very helpful blog for my Linux estate
Hello Richard,
Thanks for the feedback.We are glad to know that our article was helpful for you.