fastmon Docs
Guides

Set up Network Error Logging

Two response headers make Chromium browsers report every failed request to your site to fastmon.

Two response headers on your origin make the browser report every failed request to fastmon, including pages that never ran the tracker. Only Chromium browsers send reports. What the reports show is on Network Error Logging.

Set it up

  1. Enter the application's collector_hash in the panel below, or open this page with ?collector_hash=. Every snippet on the page then uses it.
  2. Send the two headers on every HTTPS response of each host.
  3. Make sure every host that sends them is a site of that application, or a subdomain of one.
  4. Verify that a report arrives.

Your snippet

Opened from the app, these are filled in with your application's real values. Otherwise, paste them here and every snippet on this page updates.

Find both hashes in the app under Applications → ··· → IDs & hashes.

A report whose host is no site of the application is dropped, and a report never creates a site. www.shop.example counts for shop.example, notshop.example does not.

The headers

Report-To: {"group":"fastmon","max_age":86400,"endpoints":[{"url":"https://fastmon.site/c/n/{collector_hash}"}]}NEL: {"report_to":"fastmon","max_age":86400,"success_fraction":0,"failure_fraction":1}

An application with a custom collector endpoint uses its own host instead of fastmon.site.

FieldHeaderValueWhat it does
group / report_tobothfastmonLinks the two headers. Any name works if both use the same one.
max_ageReport-To86400How long the browser keeps the endpoint, in seconds. Keep it at least as long as the NEL one.
urlReport-Tohttps://fastmon.site/c/n/{collector_hash}Where reports go.
max_ageNEL86400How long the policy stays in the browser. Every response renews it.
success_fractionNEL0Share of successful requests to report. fastmon drops those reports.
failure_fractionNEL1Share of failed requests to report. Below 1, each row counts 1 / failure_fraction, and rare errors can vanish.

Where to set them:

  • On every response, error pages included. On a site behind several addresses, an error page without the headers is lost.
  • At the outermost server you control. The ingress or load balancer answers its own 502, which the application never sees.
  • Over HTTPS only. The browser ignores a policy from a plain HTTP response.
  • On each host. www.shop.example and shop.example are two policies.

Examples

server {  listen 443 ssl;  server_name shop.example;  add_header Report-To '{"group":"fastmon","max_age":86400,"endpoints":[{"url":"https://fastmon.site/c/n/{collector_hash}"}]}' always;  add_header NEL '{"report_to":"fastmon","max_age":86400,"success_fraction":0,"failure_fraction":1}' always;}

always adds the headers to error responses. A location block with its own add_header inherits none from server, so repeat both lines there.

include_subdomains

"include_subdomains":true in the NEL header extends the policy to every subdomain of the host. For those subdomains the browser reports DNS failures only. fastmon keeps such a report when the subdomain is a site of the application, or a subdomain of the only site. A subdomain that serves its own responses is better covered by its own headers.

Verify

  1. The headers arrive. In the browser's network tab, check any response of the host for Report-To and NEL.
  2. A report goes out. Load a page in Chrome, then open a path that does not exist. The 404 has to carry both headers too. Chrome uploads an http.error report after about a minute.
  3. The endpoint answers. Test it without a browser, with a registered site in place of shop.example:
curl -i https://fastmon.site/c/n/{collector_hash} \-H 'Content-Type: application/reports+json' \--data '[{"age":0,"type":"network-error","url":"https://shop.example/missing","body":{"type":"http.error","phase":"application","status_code":404,"elapsed_time":12,"method":"GET","protocol":"http/1.1","referrer":"","sampling_fraction":1}}]'

The endpoint answers 204 whether it kept the report or dropped it. The Sites and hosts card on the dashboard shows each site's last report.

Traps

  • Cloudflare replaces your headers when its own Network Error Logging setting is on. Turn it off for the zone.
  • Shopify storefronts allow no custom response headers, so a Shopify shop cannot send a policy.
  • Report-To is required. Chromium's NEL does not read Reporting-Endpoints.
  • Each application has its own hash. A report for a site of another application drops, even in the same organization.
  • A hash rotation stops the reports silently. Put the new collector_hash into Report-To.
  • A first-party proxy has to forward /c/n/ and the browser's OPTIONS preflight. A location /c/ block covers both.
  • Removing the headers does not remove the policy. Browsers keep reporting for up to max_age seconds. To stop sooner, send NEL with "max_age":0 for a day first.

On this page