Collecting OTFP metrics

  Last updated September 04, 2018

Fastly allows you to collect and process On-the-Fly Packaging (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.

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:

     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

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 and click the Configure link.
  2. From the service menu, select the appropriate service.
  3. Click the Configuration button and then select Clone active. The Domains page appears.
  4. Click the Logging link. The logging page appears.
  5. In the list of logging endpoints, find the endpoint you enabled when setting up remote log streaming, then click Attach a condition. The Create a new condition window appears.
  6. Fill out the Create a new condition window as follows:
    • In the Name field, type a human-readable name for the condition.
    • In the Apply if field, type 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:

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

Back to Top