-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvercel_deployment_duration.pipe
More file actions
34 lines (33 loc) · 1.13 KB
/
vercel_deployment_duration.pipe
File metadata and controls
34 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
TOKEN "read" READ
TAGS "vercel"
NODE deployment_duration
SQL >
%
SELECT
{% if defined(time_range) %}
{% if time_range == 'monthly' %}
toStartOfMonth(start_time)
{% elif time_range == 'daily' %}
toStartOfDay(start_time)
{% else %}
toStartOfHour(start_time)
{% end %}
{% else %}
toStartOfHour(start_time)
{% end %} as period,
avg(dateDiff('second', start_time, end_time)) as avg_duration,
quantile(0.95)(dateDiff('second', start_time, end_time)) as p95_duration
FROM (
SELECT
event.payload.deployment.id as deployment_id,
min(event_time) as start_time,
max(event_time) as end_time
FROM vercel
WHERE event_type IN ('deployment.created', 'deployment.succeeded')
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
GROUP BY deployment_id
HAVING count(DISTINCT event_type) = 2
)
GROUP BY period
ORDER BY period ASC