RousselTMLEARNING

Observability

Grafana Faro: architecture and installation

Install Grafana Faro: the web SDK (npm or CDN), Alloy's faro.receiver, sending to Loki and Tempo, and configuring the application (name, version, environment).

1. Architecture #

One SDK, one receiver, the LGTM stack.

Components #

Available in: ✓ OSS ✓ Enterprise ✓ Cloud Self-hosted collection through Alloy; Frontend Observability in Grafana Cloud

Grafana Faro architecture
All front-end data ends up in Loki (logs, errors, measurements) and Tempo (traces).

Grafana Faro is an open source JavaScript SDK that collects front-end signals and sends them to a receiver: Grafana Alloy's faro.receiver component (self-hosted) or Grafana Cloud Frontend Observability. Data is stored in Loki and Tempo, then used in Grafana.

2. The Alloy receiver #

Receive, route, expose.

Configuration #

faro.receiver "front" {
  server {
    listen_address       = "0.0.0.0"
    listen_port          = 12347
    cors_allowed_origins = ["https://boutique.example.org"]
    api_key              = "change-moi"        // facultatif : le SDK l'envoie dans x-api-key
    max_allowed_payload_size = "5MiB"
  }
  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 }
  }
}
Common mistake: The receiver is exposed on the Internet (browsers call it): restrict cors_allowed_origins to your domains, put it behind a reverse proxy with rate limiting, and monitor its volume.

3. The SDK #

npm or CDN.

With npm #

npm install @grafana/faro-web-sdk @grafana/faro-web-tracing
import { initializeFaro, getWebInstrumentations } from '@grafana/faro-web-sdk';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';

initializeFaro({
  url: 'https://faro.example.org/collect',
  apiKey: 'change-moi',
  app: { name: 'boutique', version: '2.4.1', environment: 'production' },
  instrumentations: [
    ...getWebInstrumentations(),          // erreurs, console, Web Vitals, sessions, vues
    new TracingInstrumentation(),         // traces fetch/XHR
  ],
});

Without a build tool (CDN) #

<script src="https://unpkg.com/@grafana/faro-web-sdk@^1/dist/bundle/faro-web-sdk.iife.js"></script>
<script>
  window.GrafanaFaroWebSdk.initializeFaro({
    url: 'https://faro.example.org/collect',
    app: { name: 'vitrine', version: '1.0.0', environment: 'production' },
  });
</script>
Good practice: Always set version and environment: they let you compare two deployments and filter out staging.
Good to know: For React, Angular or Vue, dedicated integrations (for example @grafana/faro-react) add route names and rendering errors.

Related articles

Conversion funnels in RUM: measuring where users drop off

Building and reading a conversion funnel with RUM data: steps, rates, order, pitfalls, and implementation in …

Website monitoring: availability, HTTPS monitoring, certificates and performance

Set up website monitoring: availability and HTTPS checks, certificate expiry, response time, Core Web Vitals …

Real User Monitoring (RUM) and Core Web Vitals: measuring what users experience

Why observe the front end, what RUM measures, Core Web Vitals (LCP, INP, CLS) and their thresholds, and the d…

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!