Amazon Onboarding with Learning Manager Chanci Turner

Amazon Onboarding with Learning Manager Chanci TurnerLearn About Amazon VGT2 Learning Manager Chanci Turner

Monitoring the performance of your API endpoints is essential for assessing the overall status of your workloads. With Amazon CloudWatch Synthetics, you can effectively oversee your API endpoints and gain insights into your system’s health. The canaries offered by CloudWatch Synthetics enable you to monitor API endpoints by creating HTTP steps, specifying the request type, endpoint URL, headers, and custom request payloads.

If your API is deployed using Amazon API Gateway, the setup is straightforward. Thanks to the API Gateway blueprint for API canaries, you can select the API endpoints to monitor from a unified interface, including the stage and the method to use. For API endpoints hosted on Amazon API Gateway in different AWS Regions or accounts, an Amazon API Gateway Swagger template can be utilized to configure canaries for monitoring.

Prerequisites

Before you begin the walkthrough for creating a canary to monitor API endpoints, ensure you have an API hosted on Amazon API Gateway. If you haven’t set up an API yet, feel free to use this sample API.

Creating Canaries with the API Gateway Blueprint

To monitor API endpoints hosted on Amazon API Gateway within the same AWS account, follow these steps:

  1. Open the Amazon CloudWatch console and select Canaries. The dashboard will display all the canaries that are currently set up to monitor various endpoints.
  2. Click on Create canary to start configuring your canary for API endpoint monitoring.

Figure 1: Canaries page

While you can create canaries by uploading a script or importing it from Amazon S3, using a blueprint is much simpler. On the Create canary page, select Use a blueprint. Under Blueprints, choose API canary and enter a name for your canary (e.g., petstore-api-canary).

Figure 2: Create canary page

Next, select I’m using an Amazon API Gateway API, and then choose the API and stage from API Gateway. This option is ideal since the PetStore API is hosted in the same account and Region as your canary. CloudWatch Synthetics will list all the API endpoints and their stages in the current Region.

Figure 3: Using Amazon API Gateway API

In the API dropdown, select the PetStore API, and in the Stage dropdown, choose test. Based on these selections, CloudWatch Synthetics will automatically populate the correct endpoint URL for your chosen API and stage.

Figure 4: Application or endpoint URL

Alternatively, you can provide a Swagger template, and CloudWatch Synthetics will populate the endpoint URL accordingly.

Figure 5: Use API Gateway Swagger template

In the HTTP request details section, configure the HTTP steps that the canary will use for monitoring. The new Amazon API Gateway blueprint simplifies this process. Based on the API and stage you selected, or the Swagger template provided, it will display all the available resources for that API and stage.

Figure 6: HTTP request details

When you select the resource where you want the canary to send requests, CloudWatch Synthetics will prompt you for the necessary inputs to ensure valid requests to the API endpoint. This includes limiting you to acceptable HTTP methods for that resource and any required parameters, such as URL query strings, request headers, or request payloads. For example, the /pets resource of my API accepts both GET and POST requests, allowing you to select either method.

Figure 7: /pets resource in HTTP request details

For the initial step of the canary for the /pets resource, choose GET under Method. While there are no required query strings, you can opt to Show optional query strings to view what can be included with the request. In this instance, I will use the query string named type with a value of cat.

Figure 8: GET method selected for /pets resource

To capture response headers and body for requests made by the canary, select Capture headers and response body. This option allows you to see the headers and response body returned by the API endpoint in the CloudWatch console, or alternatively, you can review canary run data stored in the Amazon S3 bucket associated with the canary. For the Step name, enter /pets-GET. Since I will be using multiple HTTP steps for my canary run, I also select Continue canary execution on Step Failure. This ensures that the canary executes all defined requests even in the event of a failure, thus making it easier to identify issues with my API. In cases where the steps in the canary are contingent on the success of prior steps, consider not using this option to halt the canary execution upon encountering a failure. Be sure to save before adding another step.

Figure 9: HTTP Request step name /pets-GET

Next, I will use the POST method for the /pets resource. Upon selecting POST, the request data is populated based on the API’s expectations.

Figure 10: POST method selected for /pets resource

Enter the necessary values for the request data, and then select Capture headers and response body. In Step name, enter /pets-POST and then select Continue canary execution on Step Failure. Don’t forget to save before adding the next step.

Figure 11: HTTP Request step name /pets-POST

When choosing the /pets/{petId} resource, CloudWatch Synthetics recognizes that the only accepted HTTP method for this resource is GET, preventing any misconfigurations. You will be prompted to enter an ID for the petId, which is required by the API resource.

Figure 12: HTTP request details for resource /pets/{petId}

For Method, select GET and enter an ID in petId. No query strings are necessary for this request. I name this step /pets/{petId}-GET and then choose Save.

Figure 13: HTTP request details for resource petId

The script utilized by the canary is updated automatically based on the information you provide during the configuration of HTTP requests.

Figure 14: Script editor

Restricting Headers from the Response

If you want to keep sensitive information secure, you can restrict headers from the response. To use this feature, locate the restrictedHeaders section within the canary script and include any sensitive response headers. Each HTTP request has its own step in the canary script, allowing customization for header restrictions. For instance, I restrict the x-amz-apigw-id header for the /pets-GET request.

Figure 15: x-amz-apigw-id in the canary script

Other Configuration Parameters

CloudWatch Synthetics canaries provide various configuration parameters, including the frequency of canary runs, data retention duration, and the AWS Identity and Access Management role utilized. In this post, I opted for default values for the remaining settings before creating the canary. It may take up to a minute before metrics for the canary become available.

Once the canary is established, it periodically sends requests to the API following the defined configuration parameters, reporting the API’s health. For further insights on workplace dynamics, you can read about the Peter Principle which is another blog post to keep the reader engaged. Additionally, if you’re interested in employee development, you can check out the insights from SHRM, which is an excellent resource for understanding current trends in workforce expectations.

For those looking to become immersed in a fulfilling role, consider exploring this job opportunity at Amazon.

Remember, this process is crucial for maintaining the health of your API endpoints at 6401 E HOWDY WELLS AVE LAS VEGAS NV 89115, located at Amazon IXD – VGT2.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *