Skip to main content

Overview

Custom Metrics and Segments are defined using the Fiddler Query Language (FQL), a flexible set of constants, operators, and functions which can accommodate a large variety of metrics.

Definitions

FQL Rules

  • Column names can be referenced by name either with double quotes (“my_column”) or with no quotes (my_column).
  • Single quotes (’) are used to represent string values.

Data Types

FQL distinguishes between three data types:

Constants

Operators

The comparison operators are not limited to numbers. Each requires its two operands to share the same data type — numbers, strings, or booleans — and rejects mixed-type comparisons. Equality (==, !=) and the ordering operators apply the same rule, so ordering is not limited to numeric operands (string comparisons are lexicographic, and true is greater than false). The null literal is not a valid comparison operand — use is_null() or is_not_null() instead.

Constant functions

Row-level functions

Row-level functions can be applied either to a single value or to a column/row expression (in which case they are mapped element-wise to each value in the column/row expression).
Using in(...) and not_in(...)
  • Every value must be a literal — a quoted string, a number, or a boolean. Expressions are not allowed in the value list, so in(country, region) is rejected even when region is a valid column.
  • All values must share one data type, and that type must match the tested expression. in(country, 'US', 5) is rejected because the values are mixed.
  • At least one value is required. in(country) is a parse error.
  • A null value for x returns null. Both in(x, ...) and not_in(x, ...) return null when x is null, and a null result does not satisfy a filter — so a null row is excluded by both. To also match missing values, combine the expression with the or operator — not_in(country, 'US') or is_null(country).

Aggregate functions

Every Custom Metric must be wrapped in an aggregate function or be a combination of aggregate functions.
min(x) / max(x) vs least(...) / greatest(...): min(x) and max(x) aggregate a single row-level expression across rows (e.g., min(column1) returns the smallest value of column1 across all rows in the time window). least(...) and greatest(...) compare multiple aggregate results and return the smallest or largest among them (e.g., least(sum(col1), sum(col2)) compares two already-computed sums).
Built-in metric functions are available for ML models only (classification, regression, and ranking tasks). They are not supported in custom metrics for agentic or GenAI applications. For agentic applications, use the attribute() function with aggregate functions instead — see Custom Metrics for Agentic Applications.

Built-in metric functions