searching-mlflow-traces
Searching MLflow Traces
Trace Data Structure
- TraceInfo:
trace_id,status(OK/ERROR),timestamp_ms,execution_time_ms,tags,metadata,assessments(human feedback, evaluation results) - Spans: Tree of operations with
name,type,attributes,start_time,end_time
Workflow
- Check CLI usage (required):
mlflow traces search --help - Build filter query using syntax below
- Execute search with appropriate flags
- Retrieve details for specific traces if needed
Step 1: Check CLI Usage
mlflow traces search --help
Always run this first to get accurate flags for the installed MLflow version.
Step 2-3: Search Examples
# 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
Step 4: Retrieve Single Trace
mlflow traces get --trace-id <trace_id>
Filter Syntax
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>: assessments
Pattern operators: LIKE, ILIKE (case-insensitive), RLIKE (regex)
Python API
For mlflow.search_traces(), see: https://mlflow.org/docs/latest/genai/tracing/search-traces.md
More from b-step62/skills
agent-evaluation
Use this when you need to IMPROVE or OPTIMIZE an existing LLM agent's performance - including improving tool selection accuracy, answer quality, reducing costs, or fixing issues where the agent gives wrong/incomplete responses. Evaluates agents systematically using MLflow evaluation with datasets, scorers, and tracing. Covers end-to-end evaluation workflow or individual components (tracing setup, dataset creation, scorer definition, evaluation execution).
9searching-mlflow-docs
Searches and retrieves MLflow documentation from the official docs site. Use when the user asks about MLflow features, APIs, integrations (LangGraph, LangChain, OpenAI, etc.), tracing, tracking, or requests to look up MLflow documentation. Triggers on "how do I use MLflow with X", "find MLflow docs for Y", "MLflow API for Z".
8querying-mlflow-metrics
Fetches aggregated trace metrics (token usage, latency, trace counts, quality evaluations) from MLflow tracking servers. Triggers on requests to show metrics, analyze token usage, view LLM costs, check usage trends, or query trace statistics.
8instrumenting-with-mlflow-tracing
Instruments code with MLflow Tracing for observability. Triggers on questions about adding tracing, instrumenting agents/LLM apps, getting started with MLflow tracing, or tracing specific frameworks (LangGraph, LangChain, OpenAI, DSPy, CrewAI, AutoGen). Examples - "How do I add tracing?", "How to instrument my agent?", "How to trace my LangChain app?", "Getting started with MLflow tracing
7