Eddie Atkinson
03/30/2022, 11:13 AMprefect/task/{ECS-task-id}
. My aim is to display those logs in our webapp to show admin users the status of the flows they’ve started
Ideally I’d be able to use the ID of a flow run and use that to query the ECS task it ran on and then use that to query the logs of the flowAnna Geller
03/30/2022, 11:27 AMMy aim is to display those logs in our webapp to show admin users the status of the flows they’ve startedI'm so glad you mentioned the actual purpose of this, because this way I can show you a much better way of solving this without having to rely on CloudWatch API. Since Prefect already stores all your flow run logs in the backend, you could retrieve those easily in your web API code as follows:
from prefect.backend.flow_run import FlowRunView
flow_run = FlowRunView.from_flow_run_id(
"9549c55f-1afe-45b6-afb3-1b1ed32e7c3f"
)
logs = flow_run.get_logs()
This will give you logs in this format:
FlowRunLog(timestamp=DateTime(2022, 3, 15, 10, 3, 15, 776868, tzinfo=Timezone('+00:00')), level=20, message='some log msg')
Kevin Kho
03/30/2022, 1:45 PMEddie Atkinson
03/31/2022, 1:42 AMKevin Kho
03/31/2022, 2:22 AMEddie Atkinson
03/31/2022, 3:09 AMKevin Kho
03/31/2022, 4:25 AMEddie Atkinson
03/31/2022, 5:33 AM