ale
03/11/2022, 10:36 AMwith raw_data as
(
select "start_time"::date as task_run_date,
state,
count(id) as task_run_per_date_and_state
from public.task_run
group by 1,2
)
select state,
avg(task_run_per_date_and_state)::int as avg_task_runs_per_day
from raw_data
where state = 'Success'
group by 1
order by 1
Anna Geller
03/11/2022, 10:56 AM{
billing_usage(order_by: {timestamp: desc}) {
runs
timestamp
}
}
But just tested this and noticed this is not available on Server. So you would need to do:
query {
task_run_state_aggregate(where: {
timestamp: { _gte: "2022-03-01T00:00:00.000000+00:00" }
state: { _in: ["Success"] }
}) {
aggregate {
count
}
}
}
Then, you would need to exclude the tasks that took less than a second.
Regarding the SQL query you mentioned, I believe @Dylan had some SQL query for that purpose (I can recall I saw it in some thread but Slack deleted it by now).
Mapped child tasks are independent fully-featured Prefect tasks and they count for billing the same way as any task, i.e. they are billed only if they are successful and take longer than a second. Also note that we never bill for retries and task run failures in general.ale
03/11/2022, 11:44 AM