airflow_get_task_instance_logs
Retrieve Airflow task instance logs with filtering by error level, tailing, context lines, and size truncation to efficiently debug workflows.
Instructions
Fetch task instance logs with optional filtering and truncation.
Large log handling: Logs >100MB automatically tail to last 10,000 lines (sets auto_tailed=true).
Host-segmented responses are flattened into a single string using headers of the form --- [worker] ---,
ensuring agents can reason about multi-host output.
The tool requires an explicit try_number; callers should first retrieve it via airflow_get_task_instance.
Filter order of operations:
Auto-tail: If log >100MB, take last 10,000 lines
tail_lines: Extract last N lines from log
filter_level: Find matching lines by level (content filter)
context_lines: Add surrounding lines around matches (symmetric: N before + N after)
max_bytes: Hard cap on total output (UTF-8 safe truncation)
Parameters
instance: Instance key (optional, mutually exclusive with ui_url)
ui_url: Airflow UI URL to resolve identifiers (optional)
dag_id, dag_run_id, task_id, try_number: Task instance identifiers (required)
filter_level: "error" | "warning" | "info" (optional) - Show only lines matching level
"error": ERROR, CRITICAL, FATAL, Exception, Traceback
"warning": WARN, WARNING + error patterns
"info": INFO + warning + error patterns
context_lines: N lines before/after each match (optional, clamped to [0, 1000]; accepts int/float/str, coerced to non-negative int, fractional values truncated)
tail_lines: Extract last N lines before filtering (optional, clamped to [0, 100000]; accepts int/float/str, coerced to non-negative int, fractional values truncated)
max_bytes: Maximum response size in bytes (default: 100KB ≈ 25K tokens, clamped to 1MB)
Returns
Response dict with fields:
log: Normalized/filtered log text (host headers inserted when needed)
truncated: true if output exceeded max_bytes
auto_tailed: true if original log >100MB triggered auto-tail
bytes_returned: Actual byte size of returned log
original_lines: Line count before any filtering
returned_lines: Line count after all filtering/truncation
match_count: Number of lines matching filter_level (before context expansion)
meta.try_number: Attempt number for this task instance
meta.filters: Echo of effective filters applied (shows clamped values)
ui_url: Direct link to log view in Airflow UI
request_id: Correlates with server logs
Raises: ToolError with compact JSON payload (
code,message,request_id, optionalcontext)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dag_id | No | ||
| ui_url | No | ||
| task_id | No | ||
| instance | No | ||
| max_bytes | No | ||
| dag_run_id | No | ||
| tail_lines | No | ||
| try_number | No | ||
| filter_level | No | ||
| context_lines | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||