Skip to main content

Filter Request Logs

While fetching all Gateway request logs is useful for general monitoring, you’ll often want to filter logs based on specific criteria such as user identity, model names, etc. You can achieve this using the filters parameter in the query_spans method. The API supports the following common filter types:
  • Span fields filtering: Filter logs by span fields such as spanName, traceId, spanId, etc. See the Query Spans documentation to understand the supported options for spanFieldName and operator.
  • Span attributes filtering: Filter logs by span attributes, e.g., using tfy.model.name for model name. See Span attributes section to understand the supported options for spanAttributeKey
  • Gateway request metadata filtering: Filter logs based on Custom Metadata keys and values that you passed to Gateway requests.
The following example demonstrates how to retrieve request logs for OpenAI models submitted by a specific user, where custom metadata matches certain values: