https://prefect.io logo
Title
s

Stéphan Taljaard

02/04/2022, 6:16 AM
Hi. I'm trying to guage how much Prefect Cloud would cost. Anyone have a GraphQL query (or anything) on hand to see how many billable task runs I have? (per project/flow, and over time, would be nice)
a

Anna Geller

02/04/2022, 10:33 AM
You can use this query:
query {
  task_run_state_aggregate(where: {
      timestamp: { _gte: "2022-02-04T00:00:00.000000+00:00" }
      state: { _in: ["Success"] }
    }) {
    aggregate {
      count
    }
  }
}
But this would give you all tasks incl. those that take less than 1 sec. For billing, we exclude those, so to get more realistic number you would need to add start and end time to the query and calculate the duration in a Python script and then take out those that take less than a second. In Cloud we are not billing for: • failed task runs • task runs that took less than a second • retries
🙌 1
There is also this query, but I believe this is only in Cloud, not in Server, but you can test to confirm:
{
  billing_usage(order_by: {timestamp: desc}) {
    runs
    timestamp
  }
}
s

Stéphan Taljaard

02/04/2022, 11:25 AM
Thanks Anna. Will give feedback now
Yup it seems that one isn't in Server
{
  "errors": [
    {
      "message": "Cannot query field \"billing_usage\" on type \"Query\".",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "extensions": {
        "code": "GRAPHQL_VALIDATION_FAILED"
      }
    }
  ]
}
👍 1