Custom frontend metrics ΒΆ

Faro can send custom numeric measurements from the browser to Loki. Use this to track application-specific metrics like load times for specific components, feature usage counts, or business-relevant durations.

Send a measurement ΒΆ

Use faro.api.pushMeasurement to send named numeric values:

js

You can send multiple values in a single measurement:

js

Add context ΒΆ

Attach string key-value pairs as context for filtering:

js

Query in Grafana ΒΆ

Custom measurements are stored in Loki as structured log lines with kind=measurement. Query them with LogQL.

Filter by type ΒΆ

logql

Extract numeric values ΒΆ

Use unwrap to turn a logfmt field into a numeric sample for aggregation:

logql

Percentiles ΒΆ

logql

Count occurrences ΒΆ

logql

Naming conventions ΒΆ

GuidelineExample
Use snake_case for value namessearch_results_ms, not searchResultsMs
Include units in the nameduration_ms, size_bytes
Use a descriptive type"checkout-timing", not "custom"
Keep context values low-cardinalityEndpoints, categories β€” not UUIDs or user IDs

How it works ΒΆ

Plaintext

Measurements are sent to the Faro collector, converted to logfmt, and stored in Loki with the stream labels {app_name, kind, env}. The measurement values and context end up as logfmt fields in the log line, queryable with | logfmt and | unwrap.

No Prometheus metrics for custom measurements

Unlike Web Vitals (which are automatically extracted as Prometheus histograms), custom measurements are only stored in Loki. Use LogQL unwrap for numeric aggregation. This keeps the metric cardinality bounded while giving you full flexibility in what you measure.

Example: track component render time ΒΆ

tsx

Then query the P95 render time:

logql