Hi, I have been struggling to extract the logs for...
# ask-community
n
Hi, I have been struggling to extract the logs for flow runs from prefect cloud using the api. In prefect 1 I was able to do this with the graph ql query below. How can I do this in prefect 2?
1
Copy code
query {
    flow_run (where:{
    _and: [
    {start_time: {_gte:"%s"}},
    {start_time: {_lt:"%s"}}
    ]
    }){
    flow {
      id
      name
    }
    scheduled_start_time
    start_time
    name
    id
    version
    task_runs {
      id
      task {
        name
      }
      start_time
      end_time
      logs {
        message
        level
        id
        task_run_id
      }
    }
  }
}
c
HI Nick, Prefect 2 uses the REST API - this should help? https://docs.prefect.io/api-ref/rest-api/#/Logs/read_logs_logs_filter_post
n
thanks Ill give that a shot
z
There’s also the
OrionClient.read_logs
method
If you’re working in Python.