Hi, I am looking to get all logs for a specific ta...
# prefect-community
m
Hi, I am looking to get all logs for a specific task run, not just the flow run. Any help would be great, bit stuck.
k
Wouldn’t it be like this:
Copy code
query{
  task_run {
    id
    logs {
      id
      message
      timestamp
    }
  }
}
and then specify your task_run id? or am i missing something?
m
I see, apologies. I am now using the correct query but I am finding the logs are turning up empty, despite there being logs for the TaskRun on the UI. Any ideas? For several flow run IDs, I get all the TaskRuns back but again, no logs. This is my query:
Copy code
{
  task_run(where: {flow_run_id: {_eq: '<flow_run_id>'}}) {
    id
    logs {
      id
    }
  }
}
have also tried:
Copy code
{
  log(where :{task_run_id: {_eq:"<task_run_id>"}}) {
    id
  }
}

{
  log(where :{flow_run_id: {_eq:"<flow_run_id>"}}) {
    id
  }
}
The query to populate a FlowRunView logs works, and am trying to modify it to work with the TaskRun ID
k
Ah gotcha, you are right. will check with the team tomorrow
Maybe the
task_run_by_pk
endpoint will be better. Try this
Copy code
query{
  task_run_by_pk(id: "5bcadf0c-e5c1-42c8-b468-48c7c927712e") {
    id
    flow_run_id
    start_time
    state
    logs(
      order_by: { timestamp: desc }
    ) {
      id
      level
      message
      name
      timestamp
    }
  }
}
Which is what the UI uses here