Hello everyone — I’m using Prefect Cloud and I’m t...
# ask-community
b
Hello everyone — I’m using Prefect Cloud and I’m trying to get a count of tasks ran this month but the account -> usage view is fully empty for me saying 0 tasks have been run today. We’ve been running tasks in prefect cloud for about a month now so this seems like a bug? Or is there a better way?
a
@Bruno Murino if you go to the page https://cloud.prefect.io/admin/account, what can you see? It should include the information you’re looking for, as shown in the image. Can you show a screenshot of what you can see in the field “Usage this cycle”? (please hide any payment information that is below)
b
it’s empty as I said, though it detects the projects and flows registerd
a
what is your current Cloud Plan?
alternatively, you could run a GraphQL query with a custom condition that you need - e.g. provide this month into the $where filter:
Copy code
query TaskRunStatesCount($where: task_run_state_bool_exp) {
  task_run_state_aggregate(where: $where) {
    aggregate {
      count
    }
  }
}
You could try this:
Copy code
query {
  task_run_state_aggregate(where: {
      timestamp: { _gte: "2021-11-01T00:00:00.000000+00:00" }
      state: { _in: ["Success"] }
    }) {
    aggregate {
      count
    }
  }
}
b
I’m still on the Free plan but the idea was to monitor usage until we start reaching the free runs limit (20k)
@Anna Geller your query doesn’t factor in the tasks that run in less than 1 second so the number is wayyyyyyyyyyy higher than reality haha
😄 1
before moving to prefect cloud we were using prefect server, and the only way to get an accurate measurement was by querying the database directly with sql, but on prefect cloud that’s not an options as far as I know
a
Got it 🙂 I think once you upgrade to the Standard plan, the number of billable tasks will be displayed on that page, but you’ll still get the 20,000 free task runs. Correct, you don’t have direct access to the database, but I would see it as a benefit: exposing the underlying database directly to users adds quite a lot of risk, so opening it up only for specific queries e.g. with GraphQL is quite a standard practice.
b
yea absolutely! I’m just wondering if it would help to get a graphql function that outputs the billable tasks directly, instead of relying on counts and filters and etc
a
This actually exists! Have a look at this query:
Copy code
{
  billing_usage(order_by: {timestamp: desc}) {
    runs
    timestamp
  }
}
b
that’s very useful! However I’m getting an empty response haha probably because I’m on the free plan — I’ll move to the standard one and try again
🙌 1