Skip to content

Conversation

@aarochuk
Copy link
Contributor

Added ability to download task instance logs in airflow 3 ui as described in issue #47689
closes: #47689

@boring-cyborg boring-cyborg bot added the area:UI Related to UI/UX. For Frontend Developers. label Apr 17, 2025
const element = document.createElement("a");

element.href = URL.createObjectURL(file);
element.download = `taskInstanceLogs.txt`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks the filename for the downloaded log file. This should include dagId and taskInstance details in the name like Airflow 2 else this might keep overwriting the file on disk or create something like taskInstanceLogs(1).txt

Copy link
Contributor

@bbovenzi bbovenzi Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on ${dagId}-${taskId}-${runId}-${mapIndex}-${tryNumber}.txt

) => {
const refetchInterval = useAutoRefresh({ dagId });

const { data, ...rest } = useTaskInstanceServiceGetLog(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can pass text/plain in the accept here and get the raw value of the log file in the storage which is the value users usually want to reduce the code for formatting.

accept?: "application/json" | "text/plain" | "*/*";

if accept == Mimetype.JSON or accept == Mimetype.ANY: # default
logs, metadata = task_log_reader.read_log_chunks(ti, try_number, metadata)
encoded_token = None
if not metadata.get("end_of_log", False):
encoded_token = URLSafeSerializer(request.app.state.secret_key).dumps(metadata)
return TaskInstancesLogResponse.model_construct(continuation_token=encoded_token, content=logs)
# text/plain, or something else we don't understand. Return raw log content
# We need to exhaust the iterator before we can generate the continuation token.
# We could improve this by making it a streaming/async response, and by then setting the header using
# HTTP Trailers
logs = "".join(task_log_reader.read_log_stream(ti, try_number, metadata))
headers = None
if not metadata.get("end_of_log", False):
headers = {
"Airflow-Continuation-Token": URLSafeSerializer(request.app.state.secret_key).dumps(metadata)
}
return Response(media_type="application/x-ndjson", content=logs, headers=headers)

@bbovenzi bbovenzi changed the title Issue #47689 Implementation Add button to download task logs as a text file Apr 22, 2025
@bbovenzi bbovenzi added this to the Airflow 3.1.0 milestone Apr 30, 2025
@bbovenzi
Copy link
Contributor

bbovenzi commented May 6, 2025

@aarochuk mind rebasing and addressing PR comments?

@aarochuk
Copy link
Contributor Author

aarochuk commented May 7, 2025

@bbovenzi I will make sure to make another push by the end of the week sorry it has taken so long

@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Jun 22, 2025
@github-actions github-actions bot closed this Jun 28, 2025
@bbovenzi bbovenzi reopened this Jul 1, 2025
@bbovenzi bbovenzi requested a review from shubhamraj-git as a code owner July 1, 2025 16:05
@bbovenzi
Copy link
Contributor

bbovenzi commented Jul 1, 2025

@aarochuk are you still able to finish this PR?

@github-actions github-actions bot removed the stale Stale PRs per the .github/workflows/stale.yml policy file label Jul 2, 2025
@phanikumv
Copy link
Contributor

@aarochuk just checking in to see if you need help with this PR?

@uranusjr
Copy link
Member

Removing from 3.1.0 due to lack of response and the PR not in a working state. Please comment if anyone is interested in picking this up, we can add it back if possible.

@uranusjr uranusjr removed this from the Airflow 3.1.0 milestone Aug 13, 2025
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale Stale PRs per the .github/workflows/stale.yml policy file label Oct 10, 2025
@github-actions github-actions bot closed this Oct 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers. stale Stale PRs per the .github/workflows/stale.yml policy file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No option to download task logs on Airflow 3 UI

5 participants