Thread
#prefect-community
    Bruno Murino

    Bruno Murino

    10 months ago
    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?
    Anna Geller

    Anna Geller

    10 months ago
    @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)
    Bruno Murino

    Bruno Murino

    10 months ago
    it’s empty as I said, though it detects the projects and flows registerd
    Anna Geller

    Anna Geller

    10 months ago
    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:
    query TaskRunStatesCount($where: task_run_state_bool_exp) {
      task_run_state_aggregate(where: $where) {
        aggregate {
          count
        }
      }
    }
    You could try this:
    query {
      task_run_state_aggregate(where: {
          timestamp: { _gte: "2021-11-01T00:00:00.000000+00:00" }
          state: { _in: ["Success"] }
        }) {
        aggregate {
          count
        }
      }
    }
    Bruno Murino

    Bruno Murino

    10 months ago
    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
    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
    Anna Geller

    Anna Geller

    10 months ago
    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.
    Bruno Murino

    Bruno Murino

    10 months ago
    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
    Anna Geller

    Anna Geller

    10 months ago
    This actually exists! Have a look at this query:
    {
      billing_usage(order_by: {timestamp: desc}) {
        runs
        timestamp
      }
    }
    Bruno Murino

    Bruno Murino

    10 months ago
    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