BobDu opened a new issue, #69947:
URL: https://github.com/apache/airflow/issues/69947
### Description
Add `airflowctl tasks logs` — fetch a task instance's logs for a given try
number, mirroring the existing Core REST API endpoint `GET
/dags/{dag_id}/dagRuns/{dag_run_id}/taskInstances/{task_id}/logs/{try_number}`
(`/api/v2`).
This isn't a "migration" like the other `tasks` commands — the legacy
`airflow` CLI never had a `tasks logs` subcommand to begin with (log access has
always been webserver-UI/REST-only), so there's nothing to deprecate/mark. It's
a net-new capability for airflowctl, matching what's described in #68402 as
"another side of AIP-94."
The umbrella tracking issue #68402 lists `tasks state` /
`states-for-dag-run` / `clear` / `list` / `failed-deps` but not `logs`; checked
as of 2026-07 and found no existing issue or PR proposing this.
### Use case/motivation
Operating Airflow without direct DB/webserver access (e.g. via `kubectl
exec` or a remote API client) needs the full task-troubleshooting loop: list
failed tasks → check state → pull logs to diagnose why it failed → clear for
retry once the root cause is understood (or a transient failure is confirmed).
Every other step in that loop already has (or has an in-flight PR for) an
airflowctl command; log retrieval is the one gap still forcing a fallback to
the webserver UI or a hand-rolled REST client.
Suggested shape, matching the CLI conventions used by the in-flight `tasks
state`/`tasks clear` PRs:
`airflowctl tasks logs --dag-id <DAG> --dag-run-id <RUN> --task-id <TASK>
[--map-index <N>] [--try-number <N>]`
- `--try-number` defaults to the latest attempt if omitted (matches
webserver UI behavior).
- Should only call the primary `logs/{try_number}` endpoint. The separate
`externalLogUrl` endpoint (relevant only for Elasticsearch/OpenSearch-backed
deployments) can be left for a follow-up, to keep scope narrow.
### Related issues
- #68402 (AIP-94 umbrella tracking issue — `logs` isn't on the tracked
`tasks` checklist)
- #66173 (operations foundation) / #66174 (`tasks state`) / #66175 (`tasks
states-for-dag-run`) / #66176 (`tasks clear`)
### Are you willing to submit a PR?
- [x] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]