CloudWatch Agent

CloudWatch Agent

CloudWatch Agent

Hello Everyone

Welcome to CloudAffaire and this is Debjeet

In the last blog post, we have discussed CloudWatch Dashboard and created our 1st Dashboard.

https://cloudaffaire.com/cloudwatch-dashboard/

In this blog post, we are going to discuss CloudWatch Agent. We are also going to configure CloudWatch Agent in an EC2 instance hosting Amazon Linux 2.

CloudWatch Agent:

AWS provides CloudWatch Agent that can be used to collect and publish metrics and logs from both EC2 instances hosted in AWS and on-premises servers.

The unified CloudWatch agent enables you to do the following:

  • Collect more system-level metrics from Amazon EC2 instances, including in-guest metrics, in addition to the metrics for EC2 instances. The additional metrics are listed in Metrics Collected by the CloudWatch Agent.
  • Collect system-level metrics from on-premises servers. These can include servers in a hybrid environment as well as servers not managed by AWS.
  • Collect logs from Amazon EC2 instances and on-premises servers, running either Linux or Windows Server.
  • Retrieve custom metrics from your applications or services using the StatsD and collected protocols. StatsD is supported on both Linux servers and servers running Windows Server. collected is supported only on Linux servers.

You can store and view the metrics you collect with the CloudWatch agent in CloudWatch just as you can with any other CloudWatch metrics. The default namespace for metrics collected by the CloudWatch agent is CWAgent, although you can specify a different namespace when you configure the agent. The logs collected by the unified CloudWatch agent are processed and stored in CloudWatch Logs, just like logs collected by the older CloudWatch Logs agent. Metrics collected by the CloudWatch agent are billed as custom metrics.

The CloudWatch agent is supported on the following operating systems:

  • Amazon Linux version 2014.03.02 or later
  • Amazon Linux 2
  • Ubuntu Server version 16.04 and 14.04
  • CentOS version 7.0 and 6.5
  • Red Hat Enterprise Linux (RHEL) version 7.5, 7.4, 7.0, and 6.5
  • Debian 8.0
  • SUSE Linux Enterprise Server (SLES) 12 or later
  • 64-bit versions of Windows Server 2016, Windows Server 2012, and Windows Server 2008.

Prerequisite for CloudWatch Agent:

  • Running EC2 instance with the supported OS for CloudWatch Agent.
  • Instance configured with AWS CLI and IAM role for CloudWatch Agent.

We have already created the EC2 instance with the proper role and AWS CLI configuration.

CloudWatch Agent

CloudWatch Agent

CloudWatch Agent

Next, we are going to install and configure CloudWatch Agent.

Step 1: Connect to your EC2 instance and download the CloudWatch Agent package.

CloudWatch Agent

Step 2: Install the CloudWatch Agent

CloudWatch Agent

Files created in default installation directory

CloudWatch Agent

Step 3: Configure CloudWatch Agent using the configuration wizard

CloudWatch Agent

Note: Provide answers as per your requirement. Once the configuration wizard completes one .josn fil will be created containing CloudWatch Agent configuration details. You can also create the configuration file manually.

To view the configuration file

Step 4: Start the CloudWatch Agent with the configuration file

CloudWatch Agent

Note: If you get an error related to types.db, create an empty file

sudo mkdir /usr/share/collectd

sudo touch /usr/share/collectd/types.db

Step 5: Check the status of the CloudWatch Agent.

CloudWatch Agent

Once the Agent is started, it will publish CloudWatch Metrics as per configuration details in the configuration file. You can check the metrics in CloudWatch console under CWAgent Namespace.

CloudWatch Agent

Hope you have enjoyed this article. In the next blog post, we are going to discuss CloudWatch Alarm.

To get more details on CloudWatch, please refer below AWS documentation

https://docs.aws.amazon.com/cloudwatch/index.html

 

Leave a Reply

Close Menu