Getting Started with Amazon CloudWatch

Getting Started with Amazon CloudWatch

Unlock the Power of Monitoring with Amazon CloudWatch!

·

6 min read

Unlock the Power of Monitoring with Amazon CloudWatch! 🚀

What is CloudWatch ? 
It acts as the gatekeeper or watchman, overseeing AWS cloud activity. By utilizing its monitoring, alerting, reporting, and logging capabilities, you can effectively track activities on your AWS account.

Advantages of the Cloudwatch:

Implementing monitoring is crucial in today's landscape. CloudWatch offers the opportunity to monitor effectively, providing real-life metrics that help us understand utilization and enhance our utilization of AWS services.

What is Metrics? 

CloudWatch Metrics are data points that measure the performance and behavior of your AWS resources and applications. They provide valuable insights into the health, utilization, and efficiency of your cloud environment.

Examples of CloudWatch Metrics:

  • EC2 Instance Metrics: CPU utilization, memory usage, network traffic, disk I/O.

  • RDS Database Metrics: Connections, queries, latency, storage usage.

  • S3 Bucket Metrics: Requests, data transferred, storage usage.

  • Lambda Function Metrics: Invocations, errors, duration.

  • Custom Metrics: Create your own metrics to measure specific aspects of your applications or infrastructure.

Alarm :

CloudWatch Alarms are a powerful feature that allows you to monitor your AWS resources and applications for changes in metrics. When a metric exceeds or falls below a specified threshold, CloudWatch Alarms can trigger actions such as sending notifications or executing AWS Lambda functions.

Log insights

CloudWatch does not directly perform the cost optimization and scaling but it can integrate with other services. Like for cost optimization because it knows what activity would be having so we can integrate with Lambda functions. Being a gatekeeper it can integrate with services like lambda functions and we came to know which resources have been utilized .

We will do some practical on the CloudWatch.

Click on CloudWatch. We can see Logs, Metrics, Alarms & Dashboards.

So once we click in CloudWatch, we can see @ left pane logs.

Then Click on Logs Group . On my account we will be able to see the below log group.

What does it mean?

CloudWatch automatically created groups for my logs. So the day before yesterday I created an application in code build. All the activities that were happening in that project CloudWatch automatically created a log group & it has saved the log information inside that log group only. For better understanding we can check within that group.

Coming to below it will give all information related to your codebuild. We can check in the Log stream that each and every information related to that application is available.

We can click on the very first Log stream and find the information below.

So it has all the information regarding our builds. How many times did we rerun the build or was it successful or not?

Now the above build is the latest one but we can either check the last one as well where we got an error while build.

So everything has been captured within the log group.

We can check the Metrics. ?

Metrics is something that will help you to collect the information. It can be related to your EC2 instance, CPU, Disk Utilization, disk I/O bytes, Disk Usage.

For my account it's showing 489 Metrics.

AWS CloudWatch will automatically track the information for your AWS account using the metrics.

On the metrics below we can click on the EC2 instance.

So below is the default dashboard for the EC2 instance.

Once we click in EC2 . We have seen below 36 metrics are available.

The Per instance metrics so we are able to see categorized different metrics for the EC2 instance. Let's say we have to check CPU utilization for the instance we can see over here.

So we can pull the CPU utilization even for the last hour though my instance was in stopped state then I had pulled the utilization one day before.

So we have got the information in the different format below as per the convenience.

So here the CPU Utilization is showing “Average” since the last 15 minutes. So we can change the interval time as well.

Normally we can use the average parameter only. So we can pull the data in a certain timeframe.

So coming to the alarms part as of now we have checked the metrics.

Alarm is If the cpu has spiked to a certain percent then push an email notification . Alarms will notify us when something will happen in our environment. We will do some practical demonstrations over here.

Click on Create alarm.

Then select Metric.

Select Metric from below.

We can select the E2 instance.

Then click Per instance Metric.

Search CPU in Metrics.

We can now check cpu utilization.

I’m having only one single instance running as of now that's why it will show only one single instance otherwise if you have multiple instances it will display all the instances.

Then Select the metric.

So the Metric is there and with the instance details it has asking to select the statistics , so normally in an organization we can keep as average but here we have to for demo purposes we can keep as Maximum. We can't wait for a long time for the demo. So we can select the Maximum 1 minute.

So every 1 minute CloudWatch will watch for that EC2 instance. Within 1 minute if the maximum CPU reaches a specific point like 50% as we put it below then it will trigger an Alarm.

Now, if the CPU is reaches to the 50% in every 1 minute that we are watching anytime that we have find CPU reaches to the 50% then we will get the notification through SNS (Simple notification service topic)

Click Next.

Select the Create a new topic. Also put yours’ email id there.

Then click in create topic.

After this we will not change anything over here.

Click Next.

Click Next.

It has been configured. Once the CPU spike goes 50% then the CPU notification would be sent out.

Click on Create alarm.

We have successfully created the alarm & the State is OK.

Then , first we have to go to my mailbox and confirm subscription.

Click on Confirm Subscription.

Now click on the Alarm & will keep track of the metrics. We received the information from the Metrics.

I can connect to the instance and try to run some scripts which have already been installed in it. Then utilization would be high.

I have taken the script which increases the CPU utilization on this server , But I would not recommend running this script on your server though we are doing demo and practice purposes.

Post running the script cpu will reach 50%. Please see below:

& also an alarm has been triggered in my mailbox.

In this way we can configure the alarm to secure our infrastructure with the CloudWatch.

Happy Learning!!

Â