runabol / tork

A distributed workflow engine
https://tork.run
MIT License
577 stars 36 forks source link

feature request: Download all logs for a job #311

Closed v36372 closed 8 months ago

v36372 commented 8 months ago

Hi, I am having a need to download all logs belong to a jobs. Something like the SQL query below

SELECT
    contents
FROM
    tasks_log_parts
WHERE
    task_id in(
        SELECT
            id FROM tasks
        WHERE
            job_id = 'b9cffbdc0a24451fa09763e80eb6b4ce')
ORDER BY
    number_;

Also, may I ask why does some log lines got prepended by some random bytes like this:

Screenshot 2024-01-10 at 18 05 35
bit-wiz commented 8 months ago

Hi, I am having a need to download all logs belong to a jobs. Something like the SQL query below

SELECT
  contents
FROM
  tasks_log_parts
WHERE
  task_id in(
      SELECT
          id FROM tasks
      WHERE
          job_id = 'b9cffbdc0a24451fa09763e80eb6b4ce')
ORDER BY
  number_;

You need to download the logs in .txt right ? so could just add download button in frontend. or am I missing something here ?

runabol commented 8 months ago

@v36372 concerning the strange prefixes in the logs, the latest release should fix that.

As for getting all the task logs for a single job you could call the /tasks/:id/log endpoint for each task in your job using the APIs.

bit-wiz commented 8 months ago

@runabol I have added download btn which will download a .txt file of all the logs in frontend next js code ( in log and view both ) will this suffice what @v36372 is looking for " having a need to download all logs belong to a job "

photo_2024-01-10_20-00-41

v36372 commented 8 months ago

Thanks @runabol.

Another related observation is that the logs are reversed in order when returned from the API. I personally think it would be more intuitive if it was newest logs at the bottom and the Frontend NextJS would auto scroll to bottom when refreshed.

@bit-wiz Thank you for the download button. But did you create a PR in https://github.com/runabol/tork-web?

bit-wiz commented 8 months ago

Thanks @runabol.

Another related observation is that the logs are reversed in order when returned from the API. I personally think it would be more intuitive if it was newest logs at the bottom and the Frontend NextJS would auto scroll to bottom when refreshed.

@bit-wiz Thank you for the download button. But did you create a PR in https://github.com/runabol/tork-web?

yeah just did, I was waiting for confirmation

runabol commented 8 months ago

Another related observation is that the logs are reversed in order when returned from the API. I personally think it would be more intuitive if it was newest logs at the bottom and the Frontend NextJS would auto scroll to bottom when refreshed.

Task logs can get quite large (MBs is not uncommon in our use cases) and would tax both the backend and the UI unnecessarily. I think it's better to fetch the last page of the log and retrieve additional pages one by one as needed.