Skip to content

Commit 1769f5a

Browse files
committed
add pipes
1 parent 10c4fd5 commit 1769f5a

9 files changed

+164
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NODE branch_distribution
2+
SQL >
3+
SELECT
4+
coalesce(
5+
event.payload.deployment.meta.githubCommitRef,
6+
event.payload.deployment.meta.gitlabCommitRef
7+
) as branch,
8+
count() as deployments,
9+
round(count() * 100.0 / sum(count()) OVER (), 2) as percentage
10+
FROM vercel_logs
11+
WHERE event_type = 'deployment.created'
12+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
13+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
14+
GROUP BY branch
15+
ORDER BY deployments DESC
16+
LIMIT 10
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
NODE commit_types
2+
SQL >
3+
SELECT
4+
multiIf(
5+
lower(message) LIKE '%fix%', 'fix',
6+
lower(message) LIKE '%feat%', 'feature',
7+
lower(message) LIKE '%docs%', 'docs',
8+
lower(message) LIKE '%refactor%', 'refactor',
9+
lower(message) LIKE '%test%', 'test',
10+
lower(message) LIKE '%chore%', 'chore',
11+
'other'
12+
) as commit_type,
13+
count() as count,
14+
round(count() * 100.0 / sum(count()) OVER (), 2) as percentage
15+
FROM (
16+
SELECT
17+
coalesce(
18+
event.payload.deployment.meta.githubCommitMessage,
19+
event.payload.deployment.meta.gitlabCommitMessage
20+
) as message
21+
FROM vercel_logs
22+
WHERE event_type = 'deployment.created'
23+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
24+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
25+
)
26+
GROUP BY commit_type
27+
ORDER BY count DESC
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
NODE deployment_duration
2+
SQL >
3+
SELECT
4+
{% if defined(time_range) %}
5+
{% if time_range == 'monthly' %}
6+
toStartOfMonth(start_time)
7+
{% elif time_range == 'daily' %}
8+
toStartOfDay(start_time)
9+
{% else %}
10+
toStartOfHour(start_time)
11+
{% end %}
12+
{% else %}
13+
toStartOfHour(start_time)
14+
{% end %} as period,
15+
avg(dateDiff('second', start_time, end_time)) as avg_duration,
16+
quantile(0.95)(dateDiff('second', start_time, end_time)) as p95_duration
17+
FROM (
18+
SELECT
19+
event.payload.deployment.id as deployment_id,
20+
min(_event_time) as start_time,
21+
max(_event_time) as end_time
22+
FROM vercel_logs
23+
WHERE event_type IN ('deployment.created', 'deployment.succeeded')
24+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
25+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
26+
GROUP BY deployment_id
27+
HAVING count(DISTINCT event_type) = 2
28+
)
29+
GROUP BY period
30+
ORDER BY period DESC
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
NODE deployment_metrics
2+
SQL >
3+
SELECT
4+
count() as total_deployments,
5+
round(countIf(event_type = 'deployment.succeeded') * 100.0 / countIf(event_type = 'deployment.created'), 2) as success_rate,
6+
round(countIf(event_type = 'deployment.error') * 100.0 / countIf(event_type = 'deployment.created'), 2) as error_rate
7+
FROM vercel_logs
8+
WHERE event_type IN ('deployment.created', 'deployment.succeeded', 'deployment.error')
9+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
10+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
NODE deployments_over_time
2+
SQL >
3+
SELECT
4+
{% if defined(time_range) %}
5+
{% if time_range == 'monthly' %}
6+
toStartOfMonth(event_time)
7+
{% elif time_range == 'daily' %}
8+
toStartOfDay(event_time)
9+
{% else %}
10+
toStartOfHour(event_time)
11+
{% end %}
12+
{% else %}
13+
toStartOfHour(event_time)
14+
{% end %} as period,
15+
event_type,
16+
count() as count
17+
FROM vercel_logs
18+
WHERE event_type IN ('deployment.created', 'deployment.succeeded', 'deployment.error')
19+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
20+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
21+
GROUP BY period, event_type
22+
ORDER BY period DESC
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NODE git_analytics
2+
SQL >
3+
SELECT
4+
event.payload.deployment.meta.githubCommitAuthorName as github_author,
5+
event.payload.deployment.meta.gitlabCommitAuthorName as gitlab_author,
6+
coalesce(github_author, gitlab_author) as author,
7+
count() as commits,
8+
any(event.payload.deployment.meta.githubRepo) as github_repo,
9+
any(event.payload.deployment.meta.gitlabProjectRepo) as gitlab_repo,
10+
any(event.payload.deployment.meta.githubCommitRef) as branch
11+
FROM vercel_logs
12+
WHERE event_type = 'deployment.created'
13+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
14+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
15+
GROUP BY github_author, gitlab_author, author
16+
ORDER BY commits DESC
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
NODE git_distribution
2+
SQL >
3+
SELECT
4+
multiIf(
5+
event.payload.deployment.meta.githubRepo != '', 'GitHub',
6+
event.payload.deployment.meta.gitlabProjectRepo != '', 'GitLab',
7+
'Other'
8+
) as source,
9+
count() as deployments,
10+
round(count() * 100.0 / sum(count()) OVER (), 2) as percentage
11+
FROM vercel_logs
12+
WHERE event_type = 'deployment.created'
13+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
14+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
15+
GROUP BY source
16+
ORDER BY deployments DESC
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
NODE infrastructure_stats
2+
SQL >
3+
SELECT
4+
event.payload.regions[1] as region,
5+
event.payload.type as deployment_type,
6+
event.payload.plan as plan,
7+
count() as deployments
8+
FROM vercel_logs
9+
WHERE event_type = 'deployment.created'
10+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
11+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
12+
GROUP BY region, deployment_type, plan
13+
ORDER BY deployments DESC
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
NODE project_stats
2+
SQL >
3+
SELECT
4+
event.payload.project.id as project_id,
5+
event.payload.name as project_name,
6+
count() as total_deployments,
7+
countIf(event_type = 'deployment.error') as errors,
8+
round(countIf(event_type = 'deployment.error') * 100.0 / count(), 2) as error_rate
9+
FROM vercel_logs
10+
WHERE event_type IN ('deployment.created', 'deployment.succeeded', 'deployment.error')
11+
AND event_time >= {{DateTime(date_from, '2024-01-01 00:00:00')}}
12+
AND event_time <= {{DateTime(date_to, '2024-12-31 23:59:59')}}
13+
GROUP BY project_id, project_name
14+
ORDER BY total_deployments DESC

0 commit comments

Comments
 (0)