DEV Community

Cover image for AWS CLOUDWATCH VS UNIFIED CLOUDWATCH AGENT
Kadiri George
Kadiri George

Posted on

AWS CLOUDWATCH VS UNIFIED CLOUDWATCH AGENT

Amazon CloudWatch provides a reliable, scalable, and flexible monitoring solution that you can start using within minutes. You no longer need to set up, manage, and scale your own monitoring systems and infrastructure.

CloudWatch Metrics for EC2

  1. AWS Provided Metric (AWS pushes them)

· Basic monitoring(default): Metrics are collected at 5 minutes interval.

· Detailed monitoring(paid): Metrics are collected at 1 minute interval.

Metrics includes CPU, Network, Disk and Status checks metrics.

  1. Custom Metric (Yours to push)

· Basic Resolution: 1 minute resolution.

· High Resolution: all the way to 1 second resolution.

· Include RAM, application-level metrics.

· Make sure the IAM permission on the EC2 instance role are correct.

EC2 Included Metrics

· CPU: It include CPU utilization, credit usage and balance.

· Network: It include Network in/out of the instance

· Status check:

  • Instance status: It checks the metrics of the EC2 virtual machine.

  • System status: It checks the underlying hardware.

· Disk: It include Read/Write for Ops/Bytes (only for instance store)

Note: RAM is not included in the AWS EC2 metrics. To view metrics of EC2 RAM one need to use Unified CloudWatch Agent.

Unified CloudWatch Agent

It is used to collect addition system-level such as RAM, processes, used disk space, from EC2 instances, on premises server. The collected logs are sent to CloudWatch logs, by default no logs inside your EC2 instance will be sent to CloudWatch logs without using an agent.

Unified CloudWatch Agent – procstat plugin

It collects metrics and monitor system utilization of individual processes and support both Linux and Window servers. Examples amount of time the processes use CPU, amount of the memory the process uses….

Steps to collect metrics and logs from Amazon EC2 instances and on- premises server with CloudWatch agent.

A. Attach the appropriate role on your EC2 instance which are:

  •    CloudWatchAgentAdminPolicy
    
  •    CloudWatchAgentServerPolicy
    

B. Connect to your EC2 instance and run this command.

  • sudo yum install amazon-cloudwatch-agent and run the wizard to get started with this command sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard, follow the processes and select default choice in places you are not sure of what to select. Then specify your log file path e.g. /var/log/httpd/access_log and /var/log/httpd/error_log. I specify this path because I am running HTTPD on my server so yours may different if you are running others like apache and the likes on your server. You can also save the config file in AWS SSM Parameter Store for future use using this CloudWatchAgentAdminPolicy Role on your instance will allow put to SSM Parameter Store.

One can use this command to use the config stored in the SSM Parameter Store on a new instance.

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c ssm:AmazonCloudWatch-linux -s then check the CloudWatch log groups to find the access_log and error_log and start monitoring and also check CloudWatch metric to find CWAgent to see other metrics to monitor.

Thanks for reading.

Top comments (0)