Hi folks, I am trying to construct a graphql query...
# prefect-community
m
Hi folks, I am trying to construct a graphql query to aggregate the total number of successful task runs that we had in the past month but I am noticing that it is not so trivial to form the query so I was wondering if someone else might have already done so and is willing to share the query they used. I imagine given the intended update in prefect’s pricing that others will also want to run similar queries (in case these analytics aren’t shown somewhere on the prefect cloud UI) to track their usage.
one thing I figured is an overall aggregate
Copy code
query{
 task_run_aggregate{
  aggregate{
    count
  }
}
    
}
c
Hey Marwan - this is an interesting topic; as a public API, we have some fairly standard limits on users’ query usage, including limits on depth, size, duration, etc. of a given query. In my experience, most (if not all) aggregate queries using the user-facing GraphQL API against the task run / task run state routes will violate one of those limits. That being said, we will definitely be exposing usage trackers in the UI for billing purposes and we definitely recognize the need for more custom analytics, so we’re working on some new analytics features for this purpose -- stay tuned!
m
I see - thanks for elaborating on this. Usage trackers on the UI would definitely be helpful, but it is also nice/helpful to be able to programmatically pull some analytics for past and current usage ..
c
Yea definitely agree — just curious, what sorts of analytics questions would you like to answer? I can keep that in mind as we design the feature
m
I guess my most basic use case is to see how many task runs we had for a particular project over a certain amount of time, so I could extrapolate what our total usage would be and estimate costs accordingly
c
makes sense, noted
m
(thanks)
👍 1