Skip to main content

Filtering

Filters narrow down the rows that go into each aggregation and group. They are AND-combined; there is no OR-group support. The server enforces a per-field operator allow-list, so the exact subset of operators you can use depends on the field.

Filter object structure

For standard datasource fields, use fieldName:
{
    "fieldName": "modelName",
    "operator": "IN",
    "value": ["gpt-4", "gpt-3.5-turbo"]
}

Filterable fields

Most string fields accept the full string operator set: EQUAL, NOT_EQUAL, IN, NOT_IN, STRING_CONTAINS, STRING_NOT_CONTAINS, STRING_STARTS_WITH, STRING_NOT_STARTS_WITH, STRING_ENDS_WITH, STRING_NOT_ENDS_WITH. A few fields are narrower: providerAccountType and createdBySubjectType are comparison-only (no STRING_* operators), traceId is equality-only, and virtualModelName additionally supports IS_NULL.
FieldTypeAllowed operators
modelNamestringEQUAL, NOT_EQUAL, IN, NOT_IN, STRING_CONTAINS, STRING_NOT_CONTAINS, STRING_STARTS_WITH, STRING_NOT_STARTS_WITH, STRING_ENDS_WITH, STRING_NOT_ENDS_WITH
requestTypestringsame as modelName
virtualModelNamestringsame as modelName, plus IS_NULL
providerModelNamestringsame as modelName
errorCodestringsame as modelName
providerAccountTypestringEQUAL, NOT_EQUAL, IN, NOT_IN
createdBySubjectTypestringEQUAL, NOT_EQUAL, IN, NOT_IN
traceIdstringEQUAL
userEmailstringsame as modelName
virtualAccountstringsame as modelName
conversationIDstringsame as modelName
teamarrayARRAY_HAS_ANY, ARRAY_HAS_NONE
httpStatusCodenumberEQUAL, NOT_EQUAL, IN, NOT_IN, GREATER_THAN, LESS_THAN, GREATER_THAN_EQUAL, LESS_THAN_EQUAL
latencyMsnumberGREATER_THAN, LESS_THAN, GREATER_THAN_EQUAL, LESS_THAN_EQUAL, BETWEEN
inputTokensnumberGREATER_THAN, LESS_THAN, GREATER_THAN_EQUAL, LESS_THAN_EQUAL, BETWEEN
outputTokensnumberGREATER_THAN, LESS_THAN, GREATER_THAN_EQUAL, LESS_THAN_EQUAL, BETWEEN
costInUSDnumberGREATER_THAN, LESS_THAN, GREATER_THAN_EQUAL, LESS_THAN_EQUAL, BETWEEN
isFailurebooleanEQUAL
metadataKey / metadata.<key>stringsame as modelName
For cache-specific fields (cacheType, cacheNamespace, cacheLookupStatus, and the cache token columns), see the Cache Metrics filtering page.

Filter operators

String field operators

OperatorDescriptionExample value
EQUALExact match"alice@example.com"
NOT_EQUALNot equal to value"bot@example.com"
INMatch any value in the list["gpt-4", "gpt-3.5-turbo"]
NOT_INExclude values in the list["deprecated-model"]
STRING_CONTAINSContains substring"gpt"
STRING_NOT_CONTAINSDoes not contain substring"deprecated"
STRING_STARTS_WITHStarts with prefix"gpt-"
STRING_NOT_STARTS_WITHDoes not start with prefix"internal-"
STRING_ENDS_WITHEnds with suffix"-turbo"
STRING_NOT_ENDS_WITHDoes not end with suffix"-deprecated"
IS_NULLtrue matches rows where the field is unset; false matches rows where it is settrue

Numeric field operators

OperatorDescriptionExample value
EQUALExact match1000
NOT_EQUALNot equal to value0
INMatch any value in the list[100, 200, 300]
NOT_INExclude values in the list[0]
GREATER_THANStrictly greater than1000
LESS_THANStrictly less than5000
GREATER_THAN_EQUALGreater than or equal to100
LESS_THAN_EQUALLess than or equal to1000
BETWEENBetween two values (inclusive)[500, 5000]
IS_NULLtrue matches rows where the field is unset; false matches rows where it is settrue

Boolean field operators

OperatorDescriptionExample value
EQUALExact matchtrue
IS_NULLtrue matches rows where the field is unset; false matches rows where it is setfalse

Array field operators (used by team)

OperatorDescriptionExample value
ARRAY_HAS_ANYMatch if the array contains any of the values["team-alpha", "team-beta"]
ARRAY_HAS_NONEMatch if the array contains none of the values["excluded-team"]

Custom metadata filtering and grouping

Every datasource supports filtering and grouping by custom request-metadata keys:
  • Filter: { "metadataKey": "environment", "operator": "EQUAL", "value": "prod" }
  • Group: include "metadata.environment" in the groupBy array (string literal, prefix is metadata.).
Metadata fields are treated as strings; use the String field operators table.

Implicit team unnesting

When team is in groupBy (or used as the column of an aggregation), the server transparently UNNESTs the Teams array CTE before applying RBAC. Callers don’t need to do anything extra. Rows whose Teams array is NULL or empty drop out naturally.

Combining multiple filters

Filters are AND-combined:
{
    "startTs": "2026-04-21T00:00:00.000Z",
    "endTs": "2026-04-22T00:00:00.000Z",
    "datasource": "modelMetrics",
    "type": "distribution",
    "filters": [
        {"fieldName": "virtualModelName", "operator": "IS_NULL", "value": true},
        {"fieldName": "modelName", "operator": "IN", "value": ["gpt-4", "gpt-3.5-turbo"]},
        {"fieldName": "latencyMs", "operator": "LESS_THAN", "value": 5000},
        {"fieldName": "team", "operator": "ARRAY_HAS_ANY", "value": ["team-alpha"]},
        {"metadataKey": "environment", "operator": "IN", "value": ["production"]}
    ],
    "groupBy": ["modelName", "team"]
}