Searches and filters MLflow traces using CLI or Python API. Use when the user asks to find traces, filter traces by status/tags/metadata/execution time, query traces, or debug failed traces...
trace_id, status (OK/ERROR), timestamp_ms, execution_time_ms, tags, metadata, assessments (human feedback, evaluation results)name, type, attributes, start_time, end_timemlflow traces search --helpmlflow traces search --help
Always run this first to get accurate flags for the installed MLflow version.
# By status
mlflow traces search --experiment-id 1 --filter-string-string "trace.status = 'ERROR'"
# Output format (table or json)
mlflow traces search --experiment-id 1 --output json
# Include span details
mlflow traces search --experiment-id 1 --include-spans
# Order results
mlflow traces search --experiment-id 1 --order-by "timestamp_ms DESC"
# Pagination
mlflow traces search --experiment-id 1 --max-results 50 --page-token <token>
# Time range filter (timestamps in milliseconds since epoch)
# Get current time in ms: $(date +%s)000
# Last hour: $(( $(date +%s)000 - 3600000 ))
mlflow traces search --experiment-id 1 --filter-string "trace.timestamp_ms > $(( $(date +%s)000 - 3600000 ))"
# By execution time (slow traces > 1 second)
mlflow traces search --experiment-id 1 --filter-string "trace.execution_time_ms > 1000"
# By tag
mlflow traces search --experiment-id 1 --filter-string "tag.environment = 'production'"
# Escape special characters in tag/metadata names with backticks
mlflow traces search --experiment-id 1 --filter-string "tag.\`model-name\` = 'gpt-4'"
mlflow traces search --experiment-id 1 --filter-string "metadata.\`user.id\` = 'abc'"
# By metadata
mlflow traces search --experiment-id 1 --filter-string "metadata.user_id = 'user_123'"
# By assessment
mlflow traces search --experiment-id 1 --filter-string "feedback.rating = 'positive'"
# Combine conditions (AND only, no OR)
mlflow traces search --experiment-id 1 --filter-string "trace.status = 'ERROR' AND trace.execution_time_ms > 500"
# Full text search
mlflow traces search --experiment-id 1 --filter-string "trace.text LIKE '%error%'"
# Limit results
mlflow traces search --experiment-id 1 --filter-string "trace.status = 'OK'" --max-results 10
mlflow traces get --trace-id <trace_id>
For detailed syntax, fetch from documentation:
WebFetch(
url: "https://mlflow.org/docs/latest/genai/tracing/search-traces.md",
prompt: "Extract the filter syntax table showing supported fields, operators, and examples."
)
Common filters:
trace.status: OK, ERROR, IN_PROGRESStrace.execution_time_ms, trace.timestamp_ms: numeric comparisontag.<key>, metadata.<key>: exact match or patternspan.name, span.type: exact match or patternfeedback.<name>, expectation.<name>: assessmentsPattern operators: LIKE, ILIKE (case-insensitive), RLIKE (regex)
For mlflow.search_traces(), see: https://mlflow.org/docs/latest/genai/tracing/search-traces.md