Verifying Your AWS Lambda Function Is Running on a Schedule
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.
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:
In this Lab Step, you used CloudWatch to verify that EventBridge is running your Lambda function on a schedule once per minute.