Verifying Your AWS Lambda Function Is Running on a Schedule
Lab Steps
Introduction
Amazon CloudWatch is a fully-hosted and highly-scalable monitoring and observability service. CloudWatch can be used to monitor both AWS resources and services and applications external to AWS through integrations.
In this Lab Step, you will use CloudWatch to verify that the EventBridge schedule you created in the previous Lab Step is running your website monitoring Lambda function once per minute.
Â
Instructions
1. In the search bar at the top, enter CloudWatch, and under Services, click the CloudWatch result:
Â
2. In the left-hand side menu click All metrics under Metrics:
Â
3. To open the time-range drop-down, click custom near the top above the chart:
Â
4. In the minutes section, click 15:
You have changed the time range to 15 minutes. A time range is a time period over which to display multiple metrics. The time range can be set to a "relative" period as you have here, the last 15 minutes. Or it can be set to an "absolute" period, between two dates, as an example between the first and the third day of a specific month.Â
Â
5. In the Metrics search box, type lab-function, and press enter:
Â
6. Click Lambda > By Function Name:
You will see a list of available metrics for your Lambda function.
The list will include the following metrics:
- Invocations:Â How many times your function was ran
- ConcurrentExecutions: The number of function instances that are processing events
- Duration: How long your function took to execute
- Errors:Â How many times your function threw an exception
- Throttles: How many times your function was restricted from running due to multiple instances of the same function already running
Â
7. In the list of metrics, check the box for the Invocations metric:
Â
8. Click on the Graphed metrics tab:
Â
9. Click the Period column on the metric and select 1 Minute:
A "period"Â is the length of time associated with a specific Amazon CloudWatch statistic.
You can think of "period" as the precision of the graph. When set to 5 minutes all metric statistics in a 5 minute period are aggregated into one data point on the graph. When set to 1 minute, and when metric statistics are available at that level of granularity, the graph will show a data point for each minute.
Â
10. Look at the graph and hover your mouse cursor over it. You will see a graph similar to the following:
You will see a point on the graph for each minute the EventBridge schedule has been enabled in the last 15 minutes. Each data point represents one invocation of your Lambda function by your EventBridge schedule.
These metrics can take a few minutes to be populated in CloudWatch after creating the EventBridge schedule. If you aren't seeing any data points, wait a minute or two, and click the refresh button:
Â
Summary
In this Lab Step, you used CloudWatch to verify that EventBridge is running your Lambda function on a schedule once per minute.Â