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.
IMPORTANT: If you aren't sure how to configure OTFP, contact support@fastly.com before making any changes.
Upload custom VCL
- Before uploading custom VCL, review the caveats of mixing and matching Fastly VCL with custom VCL.
-
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:
1
%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.
- Log in to the Fastly web interface and click the Configure link.
- From the service menu, select the appropriate service.
- Click the Edit configuration button and then select Clone active. The Domains page appears.
- Click the Logging link. The logging page appears.
- 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.
- 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
.
- 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 secondssl
- video segment duration in secondsvl
- video duration in secondsrs
- 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.
Back to Top