https://prefect.io logo
b

Braun Reyes

04/27/2021, 9:56 PM
Does anyone know if there is a way to query cloud api for late flow runs?
j

Jenny

04/27/2021, 9:59 PM
Hi @Braun Reyes - We don't have a late state so you can't query for that directly. You could query for scheduled flow runs and check their scheduled_start_time against the current time. (Which is what the UI does.)
Copy code
query { flow_run (where: {state: {_eq:"Scheduled"}}){
  name
  id
  scheduled_start_time
} }
b

Braun Reyes

04/27/2021, 10:28 PM
Awesome thanks
j

Jenny

04/28/2021, 1:41 PM
Quick extra addition - if you want to put it all into your query you could use a less than operator and a datetime stamp and filter also by scheduled start time. https://hasura.io/docs/latest/graphql/core/databases/postgres/queries/query-filters.html
b

Braun Reyes

04/29/2021, 6:11 PM
yeah I got pretty gnarly graphql query going to create a health check
Copy code
{
  flow(where: {
    project: {
      name: {
        _ilike: "%-prod"
        _neq: "dex-test-prod"
      }
    }
    archived: {
      _eq: false
    }
    schedule: {
      _is_null: false
    }
  }
  ) {
    value: 
    name
    project {
      name
    }
    flow_runs_aggregate(where: {
      state: {
        _eq: "Scheduled"
      }
      scheduled_start_time: {
        _lte: "2021-04-28T21:01:46.368Z"
      }
    }
    ){
      aggregate{
        min {
          scheduled_start_time
        }
        count(columns:[flow_id],distinct: true)
      }
    }
  }
}
4 Views