Table of Contents
In this article, I will take you through the steps to create a Cloudwatch Rule Using AWS Management Console. Amazon CloudWatch is a monitoring and management service that provides data and actionable insights for AWS, hybrid, and on-premises applications and infrastructure resources. Cloudwatch enables us to monitor complete stack(applications, infrastructure, and services) in one place. It not only monitors but provide complete logs and event data to take automated actions thus reducing the overall resolution time. You can check more on CloudWatch official documentation.
Features
- CloudWatch provides up to one-second visibility of metrics and logs data.
- It has 15 months of data retention (metrics) policy.
- It generates alarms for the events to reduce the mean time to resolution(MTTR).
- CloudWatch Container Insights can be used to monitor, troubleshoot, and alert your containerized applications and microservices.
- It provides unified operational dashboard view.
- It generates alarms and provides automated actions on EKS and ECS events.
- It can analyze container and lambda metrics and can show us the graphs and dashboards with these metrics on the CloudWatch console.
- It helps in reducing overall cost and effort to resolve an application stack problem.
How to Create a Cloudwatch Rule Using AWS Management Console
Also Read: How to Create an Amazon SNS Topic Using AWS Management Console
Step 1: Prerequisites
a) You should have a valid AWS Account.
b) You should have sufficient IAM access to create resources in your account.
c) You should have required lambda function already created. If you don't have then you can check AWS documentation to know more it.
Step 2: Login to AWS Management Console
First you need to go to AWS Management Console login page and provide your credentials. Once given, Click on Sign In
.
Step 3: Open Cloudwatch Dashboard
After successful authentication, you will get redirected to AWS Management Console page as shown below. Here you need to search cloudwatch service in the search box. Once it pops up, you need to click on that Service to open CloudWatch Management Console.
Once it is opened it should show like below. To demonstrate the Cloudwatch capability we are going to create a rule that will invoke a target based on a specific event in AWS Environment.
Step 4: Create a Rule
To create a Cloudwatch Rule, Go to Events
->Rule
. Then Click on Create Rule
.
You will see a page like below where you need to select the Event Source
as Even Pattern. Then provide EC2
as the Service name and AWS API Call via CloudTrail
as the Event Type.
Since we are creating Cloudwatch rule for createvpc
operation so we will mention this in Specific operation(s) and you will notice that Event Pattern Code will change accordingly. Now under eventName section, createvpc operation will show as mentioned below.
Next you need to add the targets to invoke when an event matching your Event Pattern gets triggered. For that you need to click on Add target
.
Here you need to select Lambda Function as Target
and then Click on Configure Details
. This lambda function is the automated action that will get invoked once the event matches our Even Pattern gets triggered. This lambda function might be different for you depending on the action you want to take for your respective events.
Here you need to provide the Rule Name, Description and State. For the moment, we are providing name as createvpc
and leaving everything as it is and then Click on Create rule
.
After a moment, you will see that the rule createvpc
is created as shown below. That's all the simple steps you need to follow to create a cloudwatch rule.
Step 5: Delete Rule
If you don't need any specific rule any longer then you can choose to delete it by first selecting that rule and then click on Delete
from Actions
to delete that rule.
Once it is successfully deleted, it won't show here any longer.