RousselTMLEARNING

Observability

Faro and Alloy: receiving front-end RUM with faro.receiver

Configure faro.receiver: CORS, API key, rate limiting, source maps, then send browser errors, Web Vitals and traces to Loki and Tempo. Real results.

1. The role of faro.receiver #

The bridge between browser and backend.

The principle #

The Grafana Faro SDK collects JavaScript errors, events, Core Web Vitals and network call traces in the browser. It sends them over HTTP to faro.receiver, which listens on port 12347 by default and turns each item into a log line (to Loki) or a span (to Tempo).

From the Faro SDK to Loki and Tempo through faro.receiver

2. A production-ready configuration #

Securing a public endpoint.

config.alloy #

faro.receiver "frontend" {
  server {
    listen_address       = "0.0.0.0"
    listen_port          = 12347
    cors_allowed_origins = ["https://shop.example.com"]
    api_key              = sys.env("FARO_API_KEY")

    rate_limiting {
      strategy = "per_app"
      rate     = 50
    }
  }

  sourcemaps {
    download = false
    location {
      path                 = "/srv/sourcemaps/{{ .Release }}"
      minified_path_prefix = "https://shop.example.com/assets/"
    }
  }

  extra_log_labels = {service_name = "shop-frontend"}

  output {
    logs   = [loki.write.default.receiver]
    traces = [otelcol.exporter.otlp.tempo.input]
  }
}

loki.write "default" {
  endpoint {
    url = "http://loki:3100/loki/api/v1/push"
  }
}

otelcol.exporter.otlp "tempo" {
  client {
    endpoint = "tempo:4317"
    tls {
      insecure = true
    }
  }
}

Configuration validated with alloy validate (Alloy v1.21.3, November 2026).

Settings that matter #

SettingDefaultWhy change it
listen_address127.0.0.1The browser must reach the receiver: listen on 0.0.0.0 behind a TLS proxy.
cors_allowed_originsempty (CORS disabled)List your domains; ["*"] accepts any site.
api_keyemptyRequires the X-API-Key header; otherwise HTTP 401.
rate_limiting50 req/s, burst 100, globalper_app isolates each app and environment; beyond that, HTTP 429.
sourcemaps.downloadtrueThe receiver downloads source maps from the URL sent by the client: turn it off for untrusted traffic and serve them from disk.
max_allowed_payload_size5MiBLimits request size.
Origin, key then rate: the three checks before acceptance
Don't leave download = true on a public receiver: any client could make Alloy download the URL of its choice.

3. What Alloy receives: a real test #

Payload, responses, produced lines.

HTTP responses #

We sent a Faro payload (a log, an event, Web Vitals, an exception and a trace) to Alloy, with loki.echo and otelcol.exporter.debug to display the result:

curl -X POST http://127.0.0.1:12347/collect -H 'Content-Type: application/json' --data @payload.json
# → 401 (missing key)
curl -X POST http://127.0.0.1:12347/collect -H 'X-API-Key: secret-demo' -H 'Origin: http://127.0.0.1:8099' --data @payload.json
# → HTTP/1.1 202 Accepted
#   Access-Control-Allow-Origin: http://127.0.0.1:8099

Lines sent to Loki #

Each item becomes a logfmt line with a kind field and app, session, page and browser context (excerpt):

labels={service_name="shop-frontend"}
kind=log message="panier validé" level=info app_name=shop-frontend app_version=1.4.2 app_environment=production session_id=s-7f3a page_url=https://shop.example.com/checkout browser_name=Firefox
kind=event event_name=checkout_step event_domain=shop event_data_step=payment …
kind=measurement type=web-vitals cls=0.040000 inp=180.000000 lcp=2310.000000 …
kind=exception type=TypeError value="Cannot read properties of undefined (reading 'price')" stacktrace="TypeError: …\n  at computeTotal (https://shop.example.com/assets/app.min.js:1:4821)" …

The trace reaches Tempo as an OpenTelemetry span: HTTP POST /api/orders, service.name=shop-frontend, scope @grafana/faro-web-tracing. In Loki, filter errors:

{service_name="shop-frontend"} | logfmt | kind="exception"
quantile_over_time(0.75, {service_name="shop-frontend"} | logfmt | kind="measurement" | unwrap lcp [5m])

Sources #

Related articles

Alloy and the Grafana Labs ecosystem: which component for which tool?

The map of Alloy integrations with Faro, Beyla, k6, Loki, Mimir, Tempo, Pyroscope, Database Observability, Fl…

Beyla and Alloy: zero-code RED metrics and traces with beyla.ebpf

Enable Beyla eBPF instrumentation in Alloy: service discovery, RED metrics to Mimir, traces to Tempo, require…

Database Observability: tracking MySQL and PostgreSQL queries and plans with Alloy

Alloy's database_observability.mysql and .postgres components: collectors, execution plans, locks, sending to…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!