Skip to main content
Version: Self Hosted Turbo

Monitor AWS CloudFront

Overview

The CloudFront Plugin of SnappyFlow collects CloudFront metrics from CloudWatch and visualize them through SnappyFlow dashboard. This integration is designed to give you comprehensive insights into both CloudFront distribution and CloudFront functions.

Prerequisite

To collect metrics from CloudWatch, it is necessary to have an IAM Role with CloudWatch access and sfPoller set up within your AWS environment. Click here to learn more about setting up sfPoller in your AWS environment.

note

To monitor CloudFront, the AWS account's region should be set to us-east-1.

Create a Policy to Access CloudWatch

  1. Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/.

  2. Follow the below steps to create a policy in the IAM console.

    • Navigate to Access Management > Policies

    • In the Create policy window, go to the JSON tab

    • Copy and paste the below-mentioned JSON code into the policy editor

       {
      "Version": "2012-10-17",
      "Statement": [
      {
      "Sid": "VisualEditor0",
      "Effect": "Allow",
      "Action": [
      "cloudfront:GetMetricData",
      "cloudfront:Get*",
      "cloudfront:DescribeFunction",
      "cloudfront:List*" ,
      ],
      },
      ],
      }
    • Click the Next: Tags > Next: Review button

    • In the Review policy window, give the Name:  CloudWatchReadOnlyAccess and Description (Optional) for the policy and review the list of permissions

    • Click the Create policy button

    • Attach the  CloudWatchReadOnlyAccesspolicy to a dedicated IAM Role for read-only access

Configure sfPoller to Collect Metrics

Follow the below step to add endpoints and plugins in sfPoller.

  1. Go to the Application tab of sfPoller, navigate to your Project > Application.

  2. Select the Application, it will take you to the Endpoint page.


  3. In the Endpoint page, select the Add Endpoint button, add the following data, and save.

    • Service Type: Select AWS Service
    • Account Name: aws
    • Endpoint Type: CloudFront
    • Name: Give a meaningful name to the endpoint
    • CloudFront Type: Select a CloudFront type (Distribution or Function)
    • Instance Name: Give your instance name

  4. In the Plugins window, select the +Add button.


  5. In the Add Plugin window, select the below details and save.

    • Plugin Type: Metric

    • Plugin: cloudwatch-cloudfront

    • Enable additional metrics: By default, the status is Disabled. Enable if required.

    • Interval: Choose an interval value. The minimum value for the interval is 300

    • Status: By default, the status is Enabled

  1. Select the global Save button in the window's top right corner to save all the changes made so far.

Additional Metrics

To view additional metrics follow the below steps:

  1. Enable the additional metrics in your AWS environment. Click here to learn how to enable additional metrics in AWS.
  2. While adding the cloudwatch-cloudfront plugin enable the Enable additional metrics option.

View CloudFront Metrics

Follow the below steps to view metrics collected by CloudFront plugin.

  1. Go to the Application tab in SnappyFlow and navigate to your Project > Application > Dashboard.


  1. You can view the CloudFront metrics in the Metrics section.
note

Once plugin is added to sfPoller, they will be automatically detected within the Metrics section. However, if the plugins are not detected, you can import template to view the corresponding metrics.


  1. To access the unprocessed data gathered from the plugins, navigate to the Browse data section and choose the Index: Metric, Instance: Endpoint, Plugin, and Document Type.

Template Details

TemplatePluginDocument TypeDescription
CloudFrontcloudwatch-cloudfrontCloudfront Distribution, Cloudfront FunctionCollects metrics from cloudfront per distribution or function.

Metric List

Distribution Metrics

MetricDescription
4xxErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 4xx.
5xxErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 5xx.
BytesDownloadedThe total number of bytes downloaded by viewers for GET, HEAD, and OPTIONS requests.
BytesUploadedThe total number of bytes uploaded by the viewers to your origin with CloudFront, using POST and PUT requests.
RequestsThe total number of viewer requests received by CloudFront, for all HTTP methods and for both HTTP and HTTPS requests.
TotalErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 4xx or 5xx.

Additional Distribution Metrics

MetricDescription
cacheHitRateThe percentage of all cacheable requests for which CloudFront served the content from its cache. Errors and HTTP requests such as POST and PUT requests are not considered as cacheable requests.
503ErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 503.
504ErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 504.
401ErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 401.
404ErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 404.
502ErrorRateThe percentage of all viewer requests for which the response of the HTTP status code is 502.
OriginLatencyThe total time spent from when CloudFront receives a request to when it starts providing a response to the network (not the viewer), for requests that are served from the origin, not the CloudFront cache.

Function Metrics

MetricDescription
FunctionInvocationsThe number of times the function was started (invoked) in a given time period.
FunctionValidationErrorsThe number of validation errors produced by the function in a given time period.
FunctionExecutionErrorsThe number of execution errors that occurred in a given time period. Execution errors occur when the function fails to complete successfully.
FunctionComputeUtilizationThe amount of time that the function took to run as a percentage of the maximum allowed time.
FunctionThrottlesThe number of times that the function was throttled in a given time period.