Restart cloudwatch agent

Restart cloudwatch agent DEFAULT

Troubleshooting the CloudWatch agent

Use the following information to help troubleshoot problems with the CloudWatch agent.

CloudWatch agent command line parameters

To see the full list of parameters supported by the CloudWatch agent, enter the following at the command line at a computer where you have it installed:

Installing the CloudWatch agent using Run Command fails

To install the CloudWatch agent using Systems Manager Run Command, the SSM Agent on the target server must be version or later. If your SSM Agent isn't the correct version, you might see errors that include the following messages:

For information about updating your SSM Agent version, see Installing and Configuring SSM Agent in the AWS Systems Manager User Guide.

The CloudWatch agent won't start

If the CloudWatch agent fails to start, there might be an issue in your configuration. Configuration information is logged in the file. This file is located in on Linux servers and in on servers running Windows Server.

Verify that the CloudWatch agent is running

You can query the CloudWatch agent to find whether it's running or stopped. You can use AWS Systems Manager to do this remotely. You can also use the command line, but only to check the local server.

To query the status of the CloudWatch agent using Run Command

  1. Open the Systems Manager console at https://console.aws.amazon.com/systems-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 the button next to AmazonCloudWatch-ManageAgent.

  5. In the Action list, choose status.

  6. For Optional Configuration Source choose default and keep Optional Configuration Location blank.

  7. In the Target area, choose the instance to check.

  8. Choose Run.

If the agent is running, the output resembles the following.

If the agent is stopped, the field displays .

To query the status of the CloudWatch agent locally using the command line

  • On a Linux server, enter the following:

    On a server running Windows Server, enter the following in PowerShell as an administrator:

The CloudWatch agent won't start, and the error mentions an Amazon EC2 Region

If the agent doesn't start and the error message mentions an Amazon EC2 Region endpoint, you might have configured the agent to need access to the Amazon EC2 endpoint without granting that access.

For example, if you specify a value for the parameter in the agent configuration file that depends on Amazon EC2 metadata and you use proxies, you must make sure that the server can access the endpoint for Amazon EC2. For more information about these endpoints, see Amazon Elastic Compute Cloud (Amazon EC2) in the Amazon Web Services General Reference.

The CloudWatch agent won't start on Windows Server

On Windows Server, you might see the following error:

To fix this, first make sure that the server service is running. This error can be seen if the agent tries to start when the server service isn't running.

If the server service is already running, the following may be the issue. On some Windows Server installations, the CloudWatch agent takes more than 30 seconds to start. Because Windows Server, by default, allows only 30 seconds for services to start, this causes the agent to fail with an error similar to the following:

To fix this issue, increase the service timeout value. For more information, see A service does not start, and events and are logged in the Windows event log.

Unable to find credentials on Windows Server

On Windows Server, if you have credentials in a location other than on Windows Server , or on Windows Server , you can specify your own credential path by using the option in .

If you don’t have a credential file, you must create one. For more information, see (Optional) Modify the common configuration for proxy or Region information.

Where are the metrics?

If the CloudWatch agent has been running but you can't find metrics collected by it in the AWS Management Console or the AWS CLI, confirm that you're using the correct namespace. By default, the namespace for metrics collected by the agent is . You can customize this namespace using the field in the section of the agent configuration file. If you don't see the metrics that you expect, check the configuration file to confirm the namespace being used.

When you first download the CloudWatch agent package, the agent configuration file is . This file is in the directory where you ran the configuration wizard, or you might have moved it to a different directory. If you use the configuration wizard, the agent configuration file output from the wizard is named . For more information about the configuration file, including the field, see CloudWatch agent configuration file: Metrics section.

I updated my agent configuration but don’t see the new metrics or logs in the CloudWatch console

If you update your CloudWatch agent configuration file, the next time that you start the agent, you need to use the option. For example, if you stored the updated file on the local computer, enter the following command:

CloudWatch agent files and locations

The following table lists the files installed by and used with the CloudWatch agent, along with their locations on servers running Linux or Windows Server.

FileLinux locationWindows Server location

The control script that controls starting, stopping, and restarting the agent.

or

The log file the agent writes to. You might need to attach this when contacting AWS Support.

or

Agent configuration validation file.

or

The JSON file used to configure the agent immediately after the wizard creates it. For more information, see Create the CloudWatch agent configuration file.

The JSON file used to configure the agent if this configuration file has been downloaded from Parameter Store.

or

TOML file used to specify Region and credential information to be used by the agent, overriding system defaults.

or

Finding information about CloudWatch agent versions

To find the version number of the CloudWatch agent on a Linux server, enter the following command:

To find the version number of the CloudWatch agent on Windows Server, enter the following command:

Note

Using this command is the correct way to find the version of the CloudWatch agent. If you use Programs and Features in the Control Panel, you will see an incorrect version number.

You can also download a README file about the latest changes to the agent, and a file that indicates the version number that is currently available for download. These files are in the follow;ing locations:

  • or

  • or

Logs generated by the CloudWatch agent

The agent generates a log while it runs. This log includes troubleshooting information. This log is the file. This file is located in on Linux servers and in on servers running Windows Server.

You can configure the agent to log additional details in the file. In the agent configuration file, in the section, set the field to , then reconfigure and restart the CloudWatch agent. To disable the logging of this extra information, set the field to reconfigure and restart the agent. For more information, see Manually create or edit the CloudWatch agent configuration file.

Stopping and restarting the CloudWatch agent

You can manually stop the CloudWatch agent using either AWS Systems Manager or the command line.

To stop the CloudWatch agent using Run Command

  1. Open the Systems Manager console at https://console.aws.amazon.com/systems-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 stop.

  7. Keep Optional Configuration Source and Optional Configuration Location blank.

  8. Choose Run.

To stop the CloudWatch agent locally using the command line

  • On a Linux server, enter the following:

    On a server running Windows Server, enter the following in PowerShell as an administrator:

To restart the agent, follow the instructions in Start the CloudWatch agent.

Document Conventions

Common scenarios with the CloudWatch agent

Detect common application problems with CloudWatch Application Insights

Sours: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/troubleshooting-CloudWatch-Agent.html

Start the CloudWatch Agent

Now that your CloudWatch agent is installed on your EC2 Instance, we need to load the configuration file and restart the CloudWatch agent in order to begin collecting logs. This can be done remotely from the Systems Manager console using Run Command.

  1. Open the Systems Manager console .
  2. Choose Run command from the left side menu under Instances & Nodes. Click Run Command on the page that opens up.
  3. In the Command document box, click in the search bar. Select “Document name prefix”, then “equals”, and enter AmazonCloudWatch-ManageAgent. Select the command that appears in the results. This command sends commands directly to the CloudWatch agent on your instances by remotely running scripts on the instance. You will be sending a “configure” command with the created parameter from Parameter Store to instruct the CloudWatch agent installed on the EC2 instance to use this configuration and start collecting logs.

start-cw-agent-1

  1. Under Command parameters:
    1. Set Action to Configure.
    2. Set Mode to ec2.
    3. Set Optional Configuration Source to ssm.
    4. Set Optional Configuration Location to the name of the parameter you created in Parameter Store. If you used the name provided above, it should be called .
    5. Set Optional Restart to yes.

start-cw-agent-2

  1. Under Targets:
    1. Select Choose instances manually.
    2. You should see a list of running instances. Select the instance that was launched by the CloudFormation template you deployed for this lab. This will be named .
  2. Under Output Options, deselect Enable writing to an S3 bucket.
  3. Choose Run.
  4. 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 installed in a few seconds.

Recap: In this section, you started the CloudWatch Agent on your EC2 instance using Systems Manager Run Command. The command ran a shell script on the EC2 instance. This script instructs the CloudWatch agent to use the configuration file stored in Parameter Store, which gives the agent information on where to collect logs from, how often to collect them, and how to store them in CloudWatch. The script instructs the agent to reboot and begin collecting logs. This “enables people to perform actions at a distance” by not directly accessing the instance.

Sours: https://wellarchitectedlabs.com/security/_labs/_remote_configuration_installation_and_viewing_cloudwatch_logs/4_start_cw_agent/
  1. Lucky tuk tuk
  2. Gluten free bcaa
  3. West virginia arrest

Status of CloudWatch Agent &#; Verify, Start &#; Stop it

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.

  1. We open the Systems Manager console.
  2. Then in the navigation pane, we select Run Command.

-or-

If the AWS Systems Manager home page opens, we select Explore Run Command.

  1. In the Command document list, we select the AmazonCloudWatch-ManageAgent.
  2. In the Action list, we select status.
  3. We select the default for Optional Configuration Source.
  4. We keep Optional Configuration Location blank.
  5. Then in the Target area, we select the instance to check.
  6. Finally, we click, Run.

The output will be like this:

On the other hand, to query the status locally via the command line our Support Techs suggest:

On a Linux server:

Then on a Windows Server as an administrator, we run:

 

  • Stop and restart the CloudWatch agent

First, let us stop the agent via Run Command.

  1. To do so, we open the Systems Manager console
  2. In the navigation pane, we select the Run Command.

-or-

Like the above, if the home page opens, we select Explore Run Command.

  1. In the Command document list, we select AmazonCloudWatch-ManageAgent.
  2. Then in the Targets area, we select the instance with the CloudWatch agent.
  3. In the Action list, we select stop.
  4. We keep Optional Configuration Source and Optional Configuration Location blank.
  5. Later we select, Run.

Now, let us stop it locally via the command line.

On a Linux server:

On Windows Server:

 

  • Start the CloudWatch agent using Systems Manager Run Command

Our Support Techs recommend the below steps to start the agent via Run Command:

  1. Open the Systems Manager console.
  2. 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.

  1. In the Command document list, we select AmazonCloudWatch-ManageAgent.
  2. Then we select the instance with the CloudWatch agent in the Targets area.
  3. In the Action list, select configure.
  4. Then in the Optional Configuration Source list, select ssm.
  5. After that, in the Optional Configuration Location box, we enter the name of the agent configuration file that we created and saved.
  6. In the Optional Restart list, we can select yes.
  7. 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:

b) Linux and macOS:

On the other hand, if we save the configuration file on the local computer:

c) Windows Server:

If we save the agent configuration file in Systems Manager Parameter Store:

d) Windows Server:

Similarly, if we save the agent configuration file on the local computer:

[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.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

Sours: https://bobcares.com/blog/status-of-cloudwatch-agent/
Collect Metrics and Logs from Amazon EC2 instances with the CloudWatch Agent

Adam the Automator

TwitterFacebookLinkedIn

If you need one place to store and manage your AWS logs, look no further than Amazon CloudWatch. CloudWatch is a handy feature that helps with event correlation and is critical in maintaining visibility within your technical infrastructure.

Since Elastic Compute Cloud (EC2) Instances commonly run critical workloads, log visibility is vital, and it makes complete sense to integrate EC2 with CloudWatch.

In this tutorial, you&#;re going to learn how to set up one component of CloudWatch on your AWS EC2 instances, the CloudWatch Agent. Once configured, the agent will then send select logs to AWS CloudWatch for further investigation.

Prerequisites

This article will be a tutorial. If you plan on following along step-by-step, you will need the following:

IAM policy creation and AWS Application Programming Interface (API) permissions are outside this article&#;s scope. Always adhere to the principle of least privilege when authorizing accounts to perform actions.

  • Administrative access to an EC2 Instance running a supported operating system. This tutorial will be using an EC2 Instance running Windows Server

Creating an IAM Role

Before CloudWatch will work with an EC2 instance, it must have an IAM role. An IAM role, if properly configured for least privilege, allows CloudWatch to work correctly but without unnecessary permissions.

Let&#;s start this tutorial by creating an IAM role for CloudWatch in the AWS Management Console that leverages an AWS Managed Policy. This policy will authorize your EC2 Instance to make calls to CloudWatch.

To create an IAM role that will allow your EC2 Instance to communicate with CloudWatch:

1. Open a web browser.

2. Navigate to the AWS Management Console and sign in to your AWS account by supplying your AWS (root) or IAM account credentials.

3. Click Services on the upper left-hand corner of your screen.

AWS Management Console showing services drop-down menu.

4. Next, click IAM from the Services drop-down menu located under the Security, Identity, & Compliance category. This option will take you to the IAM console.

AWS Management Console showing services drop-down menu and IAM selection.

5. Now, click Roles from the menu on the screen&#;s left-hand side located under the Access Management category.

IAM console showing Roles selection.

6. From the Roles screen, select Create Role, located at the top of your screen.

You may see a message at the top of your screen that describes what an IAM role is. If that is the case, the Create Role option is located underneath the message.

Roles section of the IAM console showing Create Role selection.

7. On the Create Role page, designate the Type of Trusted Entity as AWS Service. AWS Service roles allow AWS services to interact with other resources (e.g. CloudWatch) on your behalf.

Create Role menu showing AWS Service selection.

8. Select the EC2 option from the list of use cases since the CloudWatch Agent will be installed on an EC2 Instance and will communicate with CloudWatch.

Create Role menu showing EC2 selection.

9. From the list of use cases, select the EC2 option and then select Next: Permissions.

Create Role menu showing EC2 and Next: Permissions selections.

On the permissions page, enter &#;CloudWatchAgentServerPolicy&#; into the search bar and then check the box to the left of the CloudWatchAgentServerPolicy&#;s Policy Name. After checking the box, select Next: Tags.

Attach permissions and policy menu showing CloudWatchAgentServerPolicy and Next: Tags selections.

The CloudWatchAgentServerPolicy contains a set of list, read, and write permissions that allow your EC2 Instance to collect and send metrics and logs to CloudWatch. The policy&#;s JavaScript Object Notation (JSON) is shown below. For more information on JSON policy elements, reference AWS documentation.

This tutorial will forego assigning tags to this role, leaving the Key and Value boxes blank, and hit Next: Review. Tags are optional key/value pairings that help manage and organize resources within AWS.

Tags menu showing Next: Review selection.

Assign your role a unique name and select Create Role. In the following screenshot, this tutorial&#;s Role name is EC2CloudWatchAgentRole.

Review menu showing Role Name and Create Role selections

Now check for the success message at the top of your screen. You should see a message that identifies the IAM role&#;s name, as shown below.

Success message showing successful role creation.

Great work! Your EC2 Instance will leverage the IAM role you created to communicate with the CloudWatch and CloudWatch Log services!

Attaching an IAM Role

Now that you&#;ve created an IAM role and attached the appropriate IAM policy, it&#;s time to attach the role to your EC2 Instance. To secure the IAM role to your EC2 Instance:

1. Assuming you&#;re still in the AWS Management Console, click Services in the upper left-hand corner of your screen.

AWS Management Console showing services drop-down menu.

2. Now click EC2 under All services. This option will take you to the EC2 console.

AWS Management Console showing services drop-down menu and EC2 selection.

3. Select Instances from the menu on the left-hand side of the screen under the Instances category.

EC2 Console showing Instances selection.

4. Within the Instances window, check the box to the left of the EC2 Instance that you will be installing the CloudWatch Agent on.

EC2 Instances window showing EC2 Instance selection.

5. Select Actions —> Security —> Modify IAM Role. The Modify IAM Role option brings you to a menu that allows you to select and attach the IAM role created earlier in this tutorial.

EC2 console showing Modify IAM Role selection.

6. Now, select the role you created earlier in this tutorial (EC2CloudWatchAgentRole) from the drop-down menu and then click Save.

IAM Role Modification menu showing IAM Role and Save selections.

7. Verify the role is attached to your EC2 Instance by viewing the success message on the top of your screen. The success message contains the IAM role name and the EC2 instance&#;s Instance ID. In the following screenshot, this tutorial&#;s IAM Role name EC2CloudWatchAgentRole and Instance ID i-0eae2dd63c30c94c2 are shown.

Success message showing successful IAM Role attachment.

Fantastic work! With the IAM role attached to your EC2 Instance, it can now communicate with the necessary CloudWatch services.

Downloading the CloudWatch Agent

Now it&#;s time to transfer the CloudWatch Agent from Amazon&#;s Simple Storage Service (S3) to your EC2 Instance. You can download the CloudWatch agent via a web browser, but this tutorial will be using PowerShell.

To download the agent with PowerShell:

1. Connect to an EC2 Instance using Remote Desktop or Session Manager.

2. Once you can see the Windows desktop, open a Windows PowerShell console session.

3. Next, download the CloudWatch Agent installation package invoking PowerShell&#;s cmdlet. This cmdlet will download the amazon-cloudwatch-agent.msi installation package to your desktop.

Related:Invoke-WebRequest: PowerShell’s Web Swiss Army Knife

4. Verify the amazon-cloudwatch-agent.msi installation package exists using PowerShell&#;s cmdlet.

Related:How to Use the PowerShell Test-Path Cmdlet

The returned value of indicates that your download was successful!

Great work! You downloaded Amazon&#;s CloudWatch Agent to your desktop.

Installing the CloudWatch Agent

In the last section, you downloaded the CloudWatch Agent, amazon-cloudwatch-agent.msi, to your desktop. Let&#;s now install the CloudWatch agent on your EC2 instance.

While still on the EC2 instance&#;s console, to install the agent:

1. Open a PowerShell console session as an Administrator.

Related:How to Run PowerShell as Administrator

2. Next, run the CloudWatch Agent MSI installer using msiexec. msiexec is a Windows-native executable that installs MSI packages. The command below uses msiexec with the install () switch to install amazon-cloudwatch-agent.msi from your desktop.

3. Once you execute the command, a window will appear that displays a progress bar. The installation process only takes a few seconds. Allow it to complete before moving to the next section.

Windows Installer window showing installation progress.

Quick and easy! The CloudWatch agent is now installed.

Configuring & Activating the CloudWatch Agent

Now that the CloudWatch Agent is installed, you must tell the agent what to collect and where to send the collected data. This configuration is defined within the JSON-based CloudWatch Agent Configuration File. To build the configuration file, the CloudWatch agent comes with a configuration wizard to accomplish this task.

The CloudWatch agent configuration wizard is not the only way to create and edit the CloudWatch agent configuration file. You can also create or edit the configuration file manually.

To trigger the wizard and configure the CloudWatch agent:

1. Open a PowerShell console session as an Administrator.

2. Launch amazon-cloudwatch-agent-config-wizard.exe by running the following code snippet. The executable program is menu-driven and will provide configurable options within your PowerShell console session.

3. Next, choose the options that you would like to apply to the configuration file. The chosen options in this tutorial keep the metric collection settings in their default state and customize the Windows event log option to collect send Security events.

When prompted with Do you want to store the config in the SSM parameter store? be sure to deviate from the default configuration and set it to 2. The value of 2 tells the configuration wizard that you do not want to store the config in Parameter Store. Using the Parameter Store is outside the scope of this tutorial.

  • On which OS are you planning to use the agent? (Default: Windows)
  • Are you using EC2 or On-Premises hosts? (Default: EC2)
  • Do you want to turn on StatsD daemon? (Default: yes)
  • Which port do you want StatsD daemon to listen to? (Default: )
  • What is the collect interval for StatsD daemon? (Default: 10s)
  • What is the aggregation interval for metrics collected by StatsD daemon? (Default: 60s)
  • Do you have any existing CloudWatch Log Agent configuration file to import for migration? (Default: no)
  • Do you want to monitor any host metrics? e.g. CPU, memory, etc. (Default: yes)
  • Do you want to monitor cpu metrics per core? Additional CloudWatch charges may apply. (Default: yes)
  • Do you want to add ec2 dimensions (ImageId, InstanceId, InstanceType, AutoScalingGroupName)
  • into all of your metrics if the info is available? (Default: yes)
  • Would you like to collect your metrics at high resolution? This enables sub-minute resolution for all metrics, but you can customize for specific metrics in the output json file. (Default 60s)
  • Which default metrics config do you want? (Default: Basic)
  • Are you satisfied with the above config? Note: it can be manually customized after the wizard
  • completes to add additional items. (Default: yes)
  • Do you want to monitor any customized log files? (Customized: 2 (no))
  • Do you want to monitor any Windows event log? (Default: yes)
  • Windows event log name: (Customized: Security)
  • Do you want to monitor VERBOSE level events for Windows event log Security? (Default: yes)
  • Do you want to monitor INFORMATION level events for Windows event log Security? (Default: yes)
  • Do you want to monitor WARNING level events for Windows event log Security? (Default: yes)
  • Do you want to monitor ERROR level events for Windows event log Security? (Default: yes)
  • Do you want to monitor CRITICAL level events for Windows event log Security? (Default: yes)
  • Log group name: (Default: Security)
  • Log stream name: (Default: [{instance_id}])
  • In which format do you want to store windows event to CloudWatch Logs?
  • (Default: XML: XML format in Windows Event Viewer)
  • Do you want to specify any additional Windows event log to monitor? (Customized: 2 (no)
  • Do you want to store the config in the SSM parameter store? (Customized: 2 (no))

4. Now, apply the CloudWatch agent configuration using the included amazon-cloudwatch-agent-ctl.ps1 PowerShell script. The following code snippet applies the agent configuration by telling the CloudWatch Agent to fetch the config from $env:ProgramFiles\Amazon\AmazonCloudWatchAgent\config.json.

The expected output of the command is shown below. In the following screenshot, you will see that the agent successfully fetched the config and validated the configuration. After the script validates the configuration, the script restarts the agent.

Command output showing the CloudWatch Agent configuration was successfully applied.

Great work! The CloudWatch agent is now installed and configured on your EC2 Instance! If you followed along, metrics and log data are now being sent to the CloudWatch service!

Next Steps

In this tutorial, you used the command line to install and configure Amazon&#;s CloudWatch agent on an EC2 Instance running a Windows operating system. You should be able to now view the metrics and logs produced by your EC2 Instance in the CloudWatch console.

As a next step, try to manually edit the CloudWatch agent config.json file to force Windows Application logs into CloudWatch. When you’re done experimenting, uninstall the CloudWatch Agent to avoid unnecessary charges!

More from Adam The Automator & Friends

Related

Sours: https://adamtheautomator.com/cloudwatch-agent/

Cloudwatch agent restart

Monitoring with AWS CloudWatch Agent

You can use AWS CloudWatch Agent to monitor your applications and resources on the AWS in real time. This section explains how to use AWS&#;CloudWatch to monitor Exasol installation on AWS.

Install and Configure CloudWatch Agent

Do the following to install and configure the CloudWatch Agent:

  1. Attach to IAM role of the EC2 instance.
  2. Access the cluster using and run the following command to download the CloudWatch package.

    wget https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/amd64/latest/amazon-cloudwatch-agent.rpm

  3. Run the following command on the nodes that should send the matrices.

    rpm -ivh amazon-cloudwatch-agent.rpm

  4. (Optional) If you want to send the matrices to a different region, modify the following file.
  5. (Optional)&#;Run the following commands to create AWS CloudWatch profile for AWS API.

    pip install pipenv

    pipenv shell

    pip install awscli

  6. (Optional)&#;Enter Key, Secret, and Region in AWS&#;Configure >&#;Profile AmazonCloudWatchAgent.
  7. Create agent configuration or use an existing one at the following location.

    It will create

  8. Run the following command to start the agent and check the syntax.

    /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

The logs are stored in the following file.

Start the CloudWatch Agent

Run the following command to start the CloudWatch Agent.

systemctl start amazon-cloudwatch-agent.service

Stop the CloudWatch Agent

Run the following command to stop the CloudWatch Agent.

systemctl stop amazon-cloudwatch-agent.service

Restart the CloudWatch Agent

Run the following command to restart the CloudWatch Agent.

systemctl restart amazon-cloudwatch-agent.service

Check Status of the CloudWatch Agent

Run the following command to check status of the CloudWatch Agent.

systemctl status amazon-cloudwatch-agent.service

Further Information

To know about the AWS CloudWatch Agent in details, see official CloudWatch Documentation.

&#;

&#;

Sours: https://docs.exasol.com/administration/aws/monitoring/aws_cloudwatch_agent.htm
Unified CloudWatch Agent for Amazon EC2

Create the CloudWatch Agent Configuration File

Before running the CloudWatch agent on any servers, you must create a CloudWatch agent configuration file.

The agent configuration file is a JSON file that specifies the metrics and logs that the agent is to collect, including custom metrics. You can create it by using the wizard or by creating it yourself from scratch. You could also use the wizard to initially create the configuration file and then modify it manually. If you create or modify the file manually, the process is more complex, but you have more control over the metrics collected and can specify metrics not available through the wizard.

Any time you change the agent configuration file, you must then restart the agent to have the changes take effect. To restart the agent, follow the instructions in Start the CloudWatch Agent.

After you have created a configuration file, you can save it manually as a JSON file and then use this file when installing the agent on your servers. Alternatively, you can store it in Systems Manager Parameter Store if you're going to use Systems Manager when you install the agent on servers.

Topics

Sours: https://github.com/awsdocs/amazon-cloudwatch-user-guide/blob/master/doc_source/create-cloudwatch-agent-configuration-file.md

You will also like:

How to Install and Configure the AWS CloudWatch Agent on a Windows Server

aws cloudwatch

Cloud servers don&#;t have to be Linux-based&#;Windows server workloads are able to run in AWS and are compatible with most of the built-in services that Amazon offers, including their CloudWatch monitoring tools, though you will have to install the agent manually.

Running servers in on-prem data center may mean having an infrastructure-monitoring solution that runs alongside each server. This solution often consumes just as many resources as the application it’s supposed to be monitoring!

In the Amazon Web Services (AWS) cloud, the same robust monitoring and logging exists without needing to worry about provisioning extra resources or configuring access. AWS’s solution to this problem is CloudWatch.

CloudWatch is an AWS service that captures the logs and server metrics from various sources. CloudWatch collects information from resources like EC2 (Elastic Compute Cloud) instances or on-prem servers. It then consolidates them into one central location in AWS.

By the end of this tutorial, you’ll be able to install the AWS CloudWatch agent on a Windows EC2 instance and configure it to send logs into CloudWatch.

Prerequisites

To follow along, you’ll need the following:

  1. An AWS Account
  2. A bit Windows Server EC2 instance OR an on-prem server running Server or later
  3. The key file associated with the instance (EC2 instances only)

Connecting to a Windows EC2 Instance

The first step in setting up CloudWatch is installing the CloudWatch agent. The agent is what sends information back to AWS that your server generates. Before you can do that though, you first need to connect to your Windows EC2 instance.

To connect to a Windows EC2 instance, you’ll need to get two pieces of information from the EC2 section in your AWS console for the Windows instance you want to login to: the Public DNS name and the key file associated with the instance.

Once you have those, go into the EC2 service from the AWS console, right-click on the instance, then select &#;Get Windows Password.&#; Once here, you’ll be prompted for the key file, and if you have the correct one, it will get you to the screen below.

You have the correct key file if you see the screen shown.If you or another administrator has already changed this password, or you don’t have access to the key file, then right-click on the instance, select &#;Terminate&#; and start over. There is no recovering keys once they are lost, and not even Amazon can recover them for you.

That being said, if you are able to retrieve the Windows password, copy it and save it for later in a password manager. Now, open a remote desktop client and log in to the server by using the Public DNS name from earlier with the credentials above. If you did everything correctly, you should see a familiar sight: The Windows server desktop.

The Windows server desktop.

Installing the CloudWatch Agent

Now that you’ve RDP’d into the instance, you can start installing the CloudWatch agent. To do so, Amazon provides you with a prebuilt .msi installer to use. Per the CloudWatch documentation, you can see under Download Link under each architecture that there are two different URLs for it: one regional and one general use. Either will work for this tutorial.

Start by opening a PowerShell window on your EC2 instance and entering the commands below. The first command will download the CloudWatch installer to the local user profile and the second will execute the installer.

Once the installer has been run, you’ll notice that a new Windows service for CloudWatch is installed on the server. This service is what allows CloudWatch to run in the background collecting the information it needs to.

Confirm that the service has been installed and is not running by using the cmdlet in the screenshot below. Don’t start it yet, you’ll need to configure it first, which you’ll do that in the next section.

Confirm that the service has been installed and is not running by using the Get-Service cmdlet.

Configuring CloudWatch

Now that the CloudWatch agent is installed, you’ll need to tell it what to report back. In addition to the preselected metrics, Amazon allows you to create custom metrics, send logs, and even report back events from Windows Event Viewer. It would be very computationally expensive to send everything back all the time and make a lot of noise. By setting a configuration, you can tell AWS what things are important and what to watch.

Amazon uses a JSON configuration file to direct the agent on which logs and metrics to collect. If you are already familiar with making these files or have been given a premade one by your organization, then you can use that. If creating configuration files is not something you are familiar with, Amazon also provides a wizard to get started.

To start the wizard, you’ll need to run it from the CloudWatch install directory. Go back to the PowerShell console and enter This command will start the wizard in an interactive session, and after answering a few questions, it will generate a JSON file with the configuration.

By default, the wizard saves the config file to the user profile as config.json, but it’s also possible to save them to the AWS Systems Manager. The Systems Manager will allow you to have the same configuration versioned and easily accessible to several instances at a time, but requires that the AWS configuration is done for each of those instances.

Following is a sample configuration file generated by the wizard. Your file might be a little different; the file below is only a basic example.

Starting the CloudWatch Agent

Now that the service has been installed and the configuration has been set, you can start the agent. Inside of your open PowerShell console, change into the CloudWatch directory by running and then run the command below to start the CloudWatch agent with the config file you just created on an EC2 instance. This command will take the config file generated by the wizard and start the service with those settings.

If you now rerun the cmdlet from earlier, you will see that the CloudWatch agent service is now running as shown below.

The CloudWatch agent service is now running.

Additionally, if you go to the CloudWatch page in the AWS console, under the &#;Metrics&#; section on the left, select the &#;All-Metrics&#; tab, then go under All > EC2 > Per-Instance Metrics, you will see your instance metrics reporting to CloudWatch as shown below.

Instance metrics reporting to CloudWatch.

Conclusion

You should now be able to set up AWS CloudWatch on Windows EC2 instances. With some small changes to the commands, the same process will work for on-prem servers, too. From here, you can set up alarms to alert you if something goes wrong, log groups to aggregate application logs from your servers, and automate the installation of the CloudWatch agent using PowerShell.

Sours: https://www.cloudsavvyit.com//how-to-install-and-configure-the-aws-cloudwatch-agent-on-a-windows-server/


1240 1241 1242 1243 1244