0% found this document useful (0 votes)
45 views

AWS Cloud Watch

The document provides a step-by-step guide to monitoring AWS resources using CloudWatch. It outlines how to [1] create a CloudWatch dashboard to visualize metrics and alarms, [2] add widgets displaying specific metrics to the dashboard, and [3] select relevant metrics like CPU utilization and network throughput for EC2 instances and S3 buckets. It also explains how to [4] set up CloudWatch alarms to define thresholds that trigger notifications when breached.

Uploaded by

ilyas2sap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

AWS Cloud Watch

The document provides a step-by-step guide to monitoring AWS resources using CloudWatch. It outlines how to [1] create a CloudWatch dashboard to visualize metrics and alarms, [2] add widgets displaying specific metrics to the dashboard, and [3] select relevant metrics like CPU utilization and network throughput for EC2 instances and S3 buckets. It also explains how to [4] set up CloudWatch alarms to define thresholds that trigger notifications when breached.

Uploaded by

ilyas2sap
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Pravin Mishra AWS

Monitoring with CloudWatch


A Step By Step Demo

Step 1: Accessing AWS Management Console........................................................................ 2


Step 2: Navigating to CloudWatch............................................................................................. 2
Step 3: Creating a CloudWatch Dashboard.............................................................................. 2
Step 4: Adding Widgets to Your Dashboard............................................................................. 3
Step 5: Selecting Metrics............................................................................................................ 4
Step 6: Setting up CloudWatch Alarms..................................................................................... 6
Step 7: Enabling Detailed Monitoring........................................................................................ 8
Step 8: Collecting Custom Application Logs..........................................................................10
Step 9: Creating CloudWatch Event Rules..............................................................................12
Conclusion:...................................................................................................................... 14

Here, we will discuss step by step how to get started with AWS
CloudWatch:

Step 1: Accessing AWS Management Console


Pravin Mishra AWS
To begin, log in to your AWS Management Console. Once you're
logged in, you'll have access to a wide range of AWS services,
including CloudWatch.

Step 2: Navigating to CloudWatch

In the AWS Management Console, search for "CloudWatch" using the


service search bar at the top. Click on the "CloudWatch" service from
the search results to open the CloudWatch dashboard.

Step 3: Creating a CloudWatch Dashboard

Creating a customized dashboard in CloudWatch allows you to have a


centralized view of your metrics, alarms, and other important
information. With a dashboard, you can visualize and monitor the
performance of your AWS resources in a single, user-friendly interface.
Here's a detailed breakdown of how to create a CloudWatch
dashboard:

1. Once you have accessed the AWS Management Console and


navigated to the CloudWatch service page, look for the
"Dashboards" option in the left navigation menu and click on it.

2. On the Dashboards page, click on the "Create dashboard"


button to initiate the process of creating a new dashboard.

3. Provide a meaningful name for your dashboard in the


"Dashboard name" field. Choose a name that reflects the
purpose or the specific resources you want to monitor. For
Pravin Mishra AWS
example, you could name it "EC2 Monitoring Dashboard" if
you primarily want to monitor your EC2 instances.

4. Optionally, you can add a description to provide additional


context or details about the dashboard.

5. Next, choose the layout for your dashboard. CloudWatch offers a


variety of layout options, including single value, line, stacked
area, and more. Select the layout that best suits your monitoring
requirements.

6. Click on the "Create dashboard" button to finalize the creation


of your dashboard.

Step 4: Adding Widgets to Your Dashboard

Once your dashboard is created, you can customize it by adding


widgets that display specific metrics and visualizations. Widgets are
like building blocks that allow you to arrange and visualize your data.
Here's how you can add widgets to your dashboard:

1. On the newly created dashboard, click on the "Add widget"


button located in the top-right corner of the dashboard.

2. Select the type of widget you want to add. CloudWatch offers


various widget types, such as line graphs, stacked area graphs,
and numerical values. Choose the widget type that best
represents the information you want to display.
Pravin Mishra AWS
3. Configure the widget settings, such as the metrics, time
range, and dimensions. You can choose preconfigured metrics
based on the AWS services you're using, set custom metrics, and
specify the statistics you want to track.

4. After configuring the widget settings, click on the "Create


widget" button to add it to your dashboard.

You can repeat the process to add multiple widgets to your dashboard,
each focusing on different metrics or resources. Rearrange and resize
the widgets on your dashboard to create a layout that best suits your
monitoring needs.

Step 5: Selecting Metrics

In CloudWatch, selecting the right metrics is key to gaining valuable


insights into the performance and health of your AWS resources. By
choosing the appropriate metrics, you can effectively monitor and
track specific aspects of your infrastructure. Let's dive into this step in
detail:

1. When adding a widget to your CloudWatch dashboard, you will


come across the option to select metrics for visualization. Click
on the "Select metric" button or similar options depending on
the widget type you have chosen.

2. CloudWatch offers a vast range of metrics that cover various AWS


services, including EC2, RDS, S3, Lambda, and more. These
preconfigured metrics provide essential information about your
resources.
Pravin Mishra AWS
3. For example, if you want to monitor the CPU utilization of an EC2
instance, you can select the "EC2" namespace and then choose
the specific instance from the available list.

4. After selecting the resource, you will see a list of available


metrics related to that resource. In the case of CPU utilization,
you can choose the "CPUUtilization" metric.

5. Once you have selected the metric, you can further refine the
data by specifying the timeframe and statistics. CloudWatch
allows you to set the time range for which you want to view the
data, such as the last hour, day, or week. Additionally, you can
select the statistics you want to track, such as average,
maximum, minimum, or sample count.

6. As you explore different metrics, you may discover additional


dimensions associated with the chosen metric. Dimensions
provide additional context and allow you to filter the data based
on specific attributes of your resources. For example, you can
filter CPU utilization by instance ID or availability zone.

7. After finalizing your metric selection, save the configuration and


observe the visualization on your CloudWatch dashboard. You will
see the metric's data presented in the form of graphs, numbers,
or other visual representations, depending on the widget type
you chose.

Remember, CloudWatch provides a rich set of metrics that allow you to


monitor various aspects of your AWS resources. Take the time to
explore the available metrics and choose the ones that are most
relevant to your monitoring needs.
Pravin Mishra AWS

Example:

Let's consider an example where you want to monitor the network


throughput of an Amazon S3 bucket. By selecting the S3 namespace,
you can choose the specific bucket and then select the
"BucketSizeBytes" metric. This metric represents the size of the
data stored in the bucket. You can further filter the data by dimensions
such as storage class or region. This will give you insights into the
amount of data flowing in and out of your S3 bucket, helping you
optimize storage and track usage patterns.

Step 6: Setting up CloudWatch Alarms

Configuring alarms in CloudWatch allows you to set up notifications


and automated actions based on specific thresholds or conditions.
Alarms are powerful tools that can alert you when metrics breach
predefined limits, helping you proactively manage your AWS
resources. Let's dive into the process of configuring alarms in
CloudWatch:

1. To configure an alarm, navigate to the "Alarms" section in the


CloudWatch console. Click on the "Create alarm" button to
initiate the alarm creation process.

2. First, you need to select a metric for the alarm. Choose the
desired AWS service and metric from the available options. For
example, if you want to monitor CPU utilization for an EC2
instance, select the EC2 service and the "CPUUtilization" metric.
Pravin Mishra AWS
3. Set the conditions for triggering the alarm. Specify the threshold
values that, when crossed, will trigger the alarm. For instance,
you can set the threshold to 80% CPU utilization.

4. Next, determine the evaluation period for the alarm. This refers
to the duration over which CloudWatch evaluates the metric data.
For example, you can set the evaluation period to 5 minutes,
which means CloudWatch will check the metric data every 5
minutes.

5. Decide on the alarm state and actions. You can define whether
the alarm should be in the "OK," "ALARM," or
"INSUFFICIENT_DATA" state. Additionally, you can choose to
receive notifications via email, SMS, or other notification
mechanisms when the alarm state changes.

6. Configure additional settings, such as the alarm name,


description, and actions to be taken when the alarm is triggered.
You can choose to execute an Auto Scaling policy, send a
notification, or even invoke an AWS Lambda function to perform
specific actions.

7. Once you've configured the alarm settings, review and confirm


the configuration. Make any necessary adjustments, if required,
and then click on the "Create alarm" button to finalize the alarm
creation.

CloudWatch alarms continuously monitor the specified metrics based


on your configuration. If the metric breaches the defined threshold
during the evaluation period, the alarm will transition to the "ALARM"
state, triggering the specified actions or notifications.
Pravin Mishra AWS
Example:

Let's consider an example where you want to set up an alarm for high
network traffic in an Elastic Load Balancer (ELB). You can select the
ELB service and choose the "HTTPCode_ELB_5XX_Count" metric, which
represents the number of HTTP 5XX error codes returned by the ELB.
Set the threshold to a specific value, such as 100, indicating that if the
count exceeds 100 within the evaluation period, the alarm will trigger.
You can configure the alarm to send an email notification to your
operations team and invoke an AWS Lambda function to automatically
scale up the ELB to handle the increased traffic.

Step 7: Enabling Detailed Monitoring

By enabling detailed monitoring, you can access metrics with a higher


frequency of data collection, providing you with more accurate insights
into resource utilization. Let's dive into the process of enabling detailed
monitoring in CloudWatch:

1. To enable detailed monitoring, you need to select the specific


AWS resource for which you want to enable it. Different
resources, such as EC2 instances or RDS databases, have
their own configurations for enabling detailed monitoring.

2. In the AWS Management Console, navigate to the resource


you want to monitor. For example, if you want to enable detailed
monitoring for an EC2 instance, go to the EC2 service page.

3. Select the instance or instances you want to enable detailed


monitoring for and navigate to their details or configuration
settings.
Pravin Mishra AWS

4. Look for the option to enable detailed monitoring. In the case of


an EC2 instance, it can be found under the "Monitoring" tab or
section.
5. Enable detailed monitoring for the selected resource, and save
the changes.

Once detailed monitoring is enabled for a resource, CloudWatch


collects metrics at a higher frequency, often every minute. This
provides you with more frequent updates on resource utilization,
performance, and other important metrics.

Example:

Let's consider an example where you have an Auto Scaling group of


EC2 instances that experiences rapid scaling events due to high traffic.
By enabling detailed monitoring for the instances within the Auto
Scaling group, you can capture metrics such as CPU utilization,
network traffic, and disk I/O at a more frequent interval. This allows
you to closely monitor resource usage during peak times and fine-tune
your scaling policies accordingly.

Step 8: Collecting Custom Application Logs

In addition to monitoring AWS resources, CloudWatch allows you to


collect and analyze custom application logs. This feature enables you
to gain insights into the behaviour and performance of your
applications, troubleshoot issues, and ensure the smooth operation of
Pravin Mishra AWS
your systems. Let's explore the process of collecting custom
application logs in CloudWatch:

1. Instrument Your Application:

To collect custom logs, you need to instrument your application


code or configure your logging framework to send logs to
CloudWatch. This can be done by integrating CloudWatch SDKs or
libraries into your application code or by utilizing existing logging
frameworks that support CloudWatch integration.

2. Configure Log Groups:

Log groups act as containers for your custom logs. They provide
a logical grouping for your logs based on the application or
system component. In the CloudWatch console, navigate to the
"Logs" section and click on "Create log group." Provide a name
for your log group, such as "MyApplicationLogs," and click
"Create."

3. Define Log Streams:

Log streams represent individual sources of logs within a log


group. For example, if you have multiple instances of an
application, each instance can have its own log stream. To create
a log stream, select the log group you created and click on
"Create log stream." Give it a name, such as
"Instance1LogStream," and click "Create."

4. Send Logs to CloudWatch:

In your application code or logging configuration, specify the


CloudWatch log group and log stream to which you want to send
Pravin Mishra AWS
the logs. Use the CloudWatch SDK or library to send log entries
to the designated log stream. Each log entry should contain
relevant information such as timestamps, log levels, and specific
log messages.

5. Log Formatting and Filtering:

Customize the log format and structure to ensure meaningful and


well-organized logs. You can include additional metadata, such as
request IDs or user identifiers, to facilitate log analysis.
Additionally, consider applying log filters to exclude or include
specific log entries based on predefined patterns or criteria.

6. Log Retention and Storage:

Determine the retention period for your logs. CloudWatch allows


you to define the number of days you want to retain your logs.
You can choose to retain logs indefinitely or set a specific
retention period based on your requirements. Be mindful of the
storage costs associated with retaining logs for extended periods.

7. Log Analysis and Insights:

Once the logs are collected in CloudWatch, you can analyze them
using CloudWatch Logs Insights. This feature allows you to run
queries and extract valuable information from your logs. You can
search for specific log entries, identify patterns, and gain insights
into application behaviour, performance, or error conditions.

Example:
Pravin Mishra AWS
Let's say you have a web application that processes customer orders.
By instrumenting your application code to send custom logs to
CloudWatch, you can track critical events such as order creation,
payment processing, and shipping status updates. With custom logs,
you can analyze the order flow, identify bottlenecks, and investigate
any anomalies or errors encountered during the process.

Step 9: Creating CloudWatch Event Rules

This automation capability enables you to streamline operations,


improve efficiency, and reduce manual intervention. Let's dive into the
process of automating actions with CloudWatch Events:

1. Create a Rule:
To get started, navigate to the "Events" section in the
CloudWatch console and click on "Create rule" to define a new
rule.

2. Define the Event Pattern or Schedule:


CloudWatch Events can be triggered based on event patterns or
schedules. If you choose the event pattern option, you can define
rules based on specific events emitted by AWS services. For
example, you can create a rule that triggers an action when an
EC2 instance state changes. If you choose the schedule option,
you can set up recurring actions at specific times or intervals.

3. Configure the Targets:


Once you've defined the event pattern or schedule, you need to
specify the target action to be performed when the rule is
Pravin Mishra AWS
triggered. CloudWatch Events supports various target types,
including AWS Lambda functions, EC2 instances, ECS tasks, SNS
topics, and more. Choose the appropriate target based on the
action you want to automate.

4. Set Up Permissions:
Ensure that the necessary permissions are in place to allow
CloudWatch Events to invoke the target action. Depending on the
target type, you may need to configure IAM roles or permissions
to grant CloudWatch Events the necessary access to perform the
action.

5. Test and Activate the Rule:


Before activating the rule, it's a good practice to test it by
simulating the event or waiting for the scheduled time to
evaluate the rule. This allows you to verify that the desired action
is triggered correctly. Once you're satisfied with the rule's
behaviour, activate it to start the automated actions.

Example:

Let's consider an example where you want to automatically scale an


application based on CPU utilization. You can create a CloudWatch
Events rule that monitors the CPU utilization metric of an EC2
instance. When the CPU utilization exceeds a certain threshold, the
rule triggers an action to invoke an AWS Lambda function. The Lambda
function, in turn, executes the necessary steps to scale up the
application by adding more instances to the Auto Scaling group.
Pravin Mishra AWS
Conclusion:

Congratulations! You have successfully learned how to set up a simple


monitoring solution using AWS CloudWatch. With CloudWatch, you can
gain valuable insights into the performance, health, and logs of your
applications and AWS resources. By following the steps outlined in this
guide, you can effectively monitor your applications, detect and
respond to issues promptly, and ensure the smooth operation of your
systems. Embrace the power of CloudWatch and take your monitoring
capabilities to the next level in the AWS cloud.

You might also like