Collecting OTFP metrics

Fastly allows you to collect and process On-the-Fly Packager (OTFP) service metrics for analysis using a combination of custom VCL updates and specific log streaming settings. Once you've set up OTFP metrics collection through remote log streaming you can use any of a number of third-party and open source software options to aggregate your logging data for visualization and further analysis.

IMPORTANT

If you aren't sure how to configure OTFP, contact support before making any changes.

Upload custom VCL

  1. Before uploading custom VCL, review the caveats of mixing and matching Fastly VCL with custom VCL.

  2. Add the following custom VCL to your Fastly VCL:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    sub vcl_deliver {
    # Identify Request type
    if (req.url.ext ~ "m3u8|ts|aac|webvtt") {
    set resp.http.Otfp-Format = "HLS";
    } else if (req.url.ext ~ "mpd|m4s") {
    set resp.http.Otfp-Format = "DASH";
    } else {
    set resp.http.Otfp-Format = "OTHER";
    }
    # Extract name-value pairs Otfp Info herder
    if (resp.http.X-Fastly-Otfp-Info) {
    set resp.http.Otfp-SS = regsub(resp.http.X-Fastly-Otfp-Info, ".*ss=(\S+).*", "\1");
    set resp.http.Otfp-SL = regsub(resp.http.X-Fastly-Otfp-Info, ".*sl=(\S+).*", "\1");
    set resp.http.Otfp-VL = regsub(resp.http.X-Fastly-Otfp-Info, ".*vl=(\S+).*", "\1");
    # Resolution (rs name-value) not available for audio-only segments
    if (resp.http.X-Fastly-Otfp-Info ~ ".*rs=(\S+).*") {
    set resp.http.Otfp-RS = re.group.1;
    } else {
    set resp.http.Otfp-RS = "-";
    }
    }
    #FASTLY deliver
    return(deliver);
    }

Create a logging endpoint

Follow the instructions to set up remote log streaming for your account and when creating your specific logging endpoint, set the Format String field to the following:

%h now.sec %r %>s %b resp.http.Otfp-Format resp.http.Otfp-SS resp.http.Otfp-SL resp.http.Otfp-VL resp.http.Otfp-RS

Control log file timing with a logging endpoint condition

To avoid excess log files, consider attaching a condition to the logging endpoint so logs are only sent when video segments are requested so that logging specifically exclude those files sent from Fastly's Origin Shield.

  1. Log in to the Fastly web interface.
  2. From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.
  3. Click Edit configuration and then select the option to clone the active version.
  4. Click Logging.
  5. In the list of logging endpoints, find the endpoint you enabled when setting up remote log streaming, then click Attach a condition.
  6. Fill out the Create a new condition window as follows:
    • In the Name field, enter a human-readable name for the condition.
    • In the Apply if field, enter resp.http.X-Fastly-Otfp-Info && !req.http.Fastly-FF.
  7. Click Save and apply to.

Analyze logging data

In addition to any Varnish variable, and a variety of Fastly's extensions to VCL, log files include the following video-specific fields:

  • ss - video segment start presentation time in seconds
  • sl - video segment duration in seconds
  • vl - video duration in seconds
  • rs - video track display resolution in pixels

You can use these fields to run queries for analysis and use what you discover to refine your video delivery settings.

Was this guide helpful?

Do not use this form to send sensitive information. If you need assistance, contact support. This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.