How to setup AWS CloudWatch Agent for Custom Metrics?

How to setup AWS CloudWatch Agent for Custom Metrics?

August 16, 2018 / Eternal Team

AWS provides lots of services and data. But it is also true that some metrics are not available in aws default metrics. That’s why we have to setup custom metrics like Memory, Disk and Swap uses etc. which are very necessary to monitor and maintain the servers.

We can push custom metrics by two methods:

MonScripts Setup

CloudWatch Agent setup

Monitoring By CloudWatch Agent:

We can setup custom metrics data pushing setup in ec2 instance by above methods. CloudWatch Agent Method is much reliable and effective with compare to Monscripts setup. In Cloudwatch Agent method, we don’t need to setup any cron job to send custom metrics data to cloudwatch. The CloudWatch Agent manage all these automatically as predefined. It works simultaneously with AWS cloudWatch service.

CloudWatch agent enables you to do Collect more system-level metrics from Amazon EC2 instances, including in-guest metrics, in addition to the metrics listed in Amazon EC2 Metrics and Dimensions. The additional metrics are listed in Metrics Collected by the CloudWatch Agent.

Create the IAM roles and users that you need for the CloudWatch agent. They enable CloudWatch to collect metrics from the server, and to integrate with AWS Systems Manager. Create Role and User with CloudWatchAgentServerPolicy and AmazonEC2RoleforSSM policy.

Download the agent package. First make directory cloudwatch agent and change directory to cloudwatch agent.

Whether you are installing the CloudWatch agent on an Amazon EC2 instance or an on-premises server, you must create the CloudWatch agent configuration file before starting the agent. The agent configuration file is a JSON file that specifies the metrics and logs that the agent is to collect. 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.

So now here we will use wizard to create cloudwatch agent configuration file. It will create file automatically as our answer.

The agent configuration file wizard, amazon-cloudwatch-agent-config-wizard, asks a series of questions, including the following:

Are you installing the agent on an Amazon EC2 instance or an on-premises server?

Is the server running Linux or Windows Server?

Do you want the agent to also send log files to CloudWatch Logs? If so, do you have an existing CloudWatch Logs agent configuration file? If yes, the CloudWatch agent can use this file to determine the logs to collect from the server.

If you are going to collect metrics from the server, do you want to monitor one of the default sets of metrics, or customize the list of metrics that you collect?

Now Check your CloudWatch Service. In metrics section you would be seeing the data collected by CloudWatch Agent metrics. Explore these metrics and set dashboard and create necessary alarms as you want for seamless experience of AWS infrastructure.

If you are having any trouble in setting up a AWS infrastructure, you can contact us and we will design the AWS architecture as per your requirements and help you to set-up the whole AWS infrastructure.