-
-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbf8956
commit 5b798e1
Showing
17 changed files
with
266 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
packages/tinybird/datasources/__ttl_7d_count_mv.datasource
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
VERSION 1 | ||
# Data Source created from Pipe '__ttl_7d_count__v1' | ||
|
||
SCHEMA > | ||
`time` DateTime, | ||
`monitorId` String, | ||
`url` String, | ||
`count` AggregateFunction(count), | ||
`ok` AggregateFunction(count, Nullable(UInt8)) | ||
|
||
ENGINE "AggregatingMergeTree" | ||
ENGINE_PARTITION_KEY "toYYYYMM(time)" | ||
ENGINE_SORTING_KEY "time, monitorId, url" | ||
ENGINE_TTL "time + toIntervalDay(7)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
SCHEMA > | ||
`description` String `json:$.description`, | ||
`fetched_at` Int64 `json:$.fetched_at`, | ||
`indicator` String `json:$.indicator`, | ||
`name` String `json:$.name`, | ||
`time_zone` String `json:$.time_zone`, | ||
`updated_at` Int64 `json:$.updated_at`, | ||
`url` String `json:$.url` | ||
|
||
ENGINE "MergeTree" | ||
ENGINE_SORTING_KEY "description, time_zone, updated_at, url" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
VERSION 0 | ||
|
||
SCHEMA > | ||
`monitorId` Int32 `json:$.monitorId`, | ||
`region` String `json:$.region`, | ||
`timestamp` Int64 `json:$.timestamp`, | ||
`timing` String `json:$.timing`, | ||
`workspaceId` Int32 `json:$.workspaceId`, | ||
`latency` Int64 `json:$.latency`, | ||
`errorMessage` Nullable(String) `json:$.errorMessage`, | ||
`error` Int16 `json:$.error` | ||
|
||
ENGINE "MergeTree" | ||
ENGINE_PARTITION_KEY "toYYYYMM(fromUnixTimestamp64Milli(timestamp))" | ||
ENGINE_SORTING_KEY "monitorId, workspaceId" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
VERSION 0 | ||
|
||
SCHEMA > | ||
`browser` String `json:$.browser`, | ||
`city` String `json:$.city`, | ||
`continent` String `json:$.continent`, | ||
`country` String `json:$.country`, | ||
`device` String `json:$.device`, | ||
`dsn` String `json:$.dsn`, | ||
`href` String `json:$.href`, | ||
`id` String `json:$.id`, | ||
`name` String `json:$.name`, | ||
`os` String `json:$.os`, | ||
`path` String `json:$.path`, | ||
`rating` String `json:$.rating`, | ||
`region_code` String `json:$.region_code`, | ||
`screen` String `json:$.screen`, | ||
`session_id` String `json:$.session_id`, | ||
`speed` String `json:$.speed`, | ||
`timezone` String `json:$.timezone`, | ||
`value` Float32 `json:$.value`, | ||
`timestamp` Nullable(DateTime) `json:$.timestamp` | ||
|
||
ENGINE "MergeTree" | ||
ENGINE_SORTING_KEY "session_id, speed, timezone" |
23 changes: 23 additions & 0 deletions
23
packages/tinybird/pipes/__ttl_14d_chart_all_regions_get.pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
VERSION 1 | ||
TOKEN "__ttl_14d_chart_all_regions_get__v1_endpoint_read_6659" READ | ||
|
||
NODE __ttl_14d_chart_all_regions_get_0 | ||
SQL > | ||
|
||
% | ||
SELECT | ||
toStartOfInterval( | ||
toDateTime(cronTimestamp / 1000), INTERVAL 1 HOUR | ||
) as h, | ||
toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp, | ||
round(quantile(0.5)(latency)) as p50Latency, | ||
round(quantile(0.75)(latency)) as p75Latency, | ||
round(quantile(0.9)(latency)) as p90Latency, | ||
round(quantile(0.95)(latency)) as p95Latency, | ||
round(quantile(0.99)(latency)) as p99Latency | ||
FROM __ttl_14d_mv | ||
WHERE monitorId = {{ String(monitorId, '1') }} | ||
GROUP BY h | ||
ORDER BY h DESC | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
VERSION 1 | ||
TOKEN "__ttl_45d_statuspage_get_endpoint_read_1959" READ | ||
|
||
NODE __ttl_45d_statuspage_get_0 | ||
SQL > | ||
|
||
% | ||
SELECT | ||
toDateTime(cronTimestamp / 1000, 'UTC') AS day, | ||
-- only for debugging purposes | ||
toTimezone(day, {{ String(timezone, 'Europe/London') }}) as with_timezone, | ||
toStartOfDay(with_timezone) as start_of_day, | ||
statusCode | ||
-- latency | ||
FROM __ttl_45d_mv | ||
WHERE monitorId = {{ String(monitorId, '4') }} | ||
|
||
|
||
|
||
NODE __ttl_7d_statuspage_get_1 | ||
SQL > | ||
|
||
% | ||
SELECT | ||
start_of_day as day, | ||
count() AS count, | ||
count(multiIf((statusCode >= 200) AND (statusCode <= 299), 1, NULL)) AS ok | ||
FROM __ttl_45d_statuspage_get_0 | ||
GROUP BY start_of_day | ||
ORDER BY start_of_day DESC | ||
WITH FILL | ||
FROM | ||
toStartOfDay(toTimezone(now(), {{ String(timezone, 'Europe/London') }})) | ||
TO toStartOfDay( | ||
toTimezone(date_sub(DAY, 46, now()), {{ String(timezone, 'Europe/London') }}) | ||
) STEP INTERVAL -1 DAY | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
packages/tinybird/pipes/__ttl_7d_chart_all_regions_get.pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
VERSION 1 | ||
TOKEN "__ttl_7d_chart_all_regions_get__v1_endpoint_read_8648" READ | ||
|
||
NODE __ttl_7d_chart_all_regions_get_0 | ||
SQL > | ||
|
||
% | ||
SELECT | ||
toStartOfInterval( | ||
toDateTime(cronTimestamp / 1000), INTERVAL 1 HOUR | ||
) as h, | ||
toUnixTimestamp64Milli(toDateTime64(h, 3)) as timestamp, | ||
round(quantile(0.5)(latency)) as p50Latency, | ||
round(quantile(0.75)(latency)) as p75Latency, | ||
round(quantile(0.9)(latency)) as p90Latency, | ||
round(quantile(0.95)(latency)) as p95Latency, | ||
round(quantile(0.99)(latency)) as p99Latency | ||
FROM __ttl_7d_mv | ||
WHERE monitorId = {{ String(monitorId, '1') }} | ||
GROUP BY h | ||
ORDER BY h DESC | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
VERSION 1 | ||
DESCRIPTION > | ||
TODO: descripe what it is for! | ||
|
||
|
||
NODE __ttl_7d_count_0 | ||
SQL > | ||
|
||
SELECT | ||
time, | ||
monitorId, | ||
url, | ||
countState() AS count, | ||
countState(if(error = 0, 1, NULL)) AS ok | ||
FROM __ttl_45d_mv | ||
GROUP BY | ||
time, | ||
monitorId, | ||
url | ||
|
||
TYPE materialized | ||
DATASOURCE __ttl_7d_count_mv | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
VERSION 1 | ||
TOKEN "__ttl_7d_count_get__v1_endpoint_read_7412" READ | ||
|
||
NODE __ttl_7d_count_get_0 | ||
SQL > | ||
|
||
% | ||
SELECT time as day, countMerge(count) as count, countMerge(ok) as ok | ||
FROM __ttl_7d_count_mv_test | ||
WHERE | ||
monitorId = {{ String(monitorId, '4') }} | ||
{% if defined(url) %} AND url = {{ String(url) }} {% end %} | ||
GROUP BY day | ||
ORDER BY day DESC | ||
WITH FILL | ||
FROM | ||
toStartOfDay(now()) | ||
TO toStartOfDay( | ||
date_sub(DAY, 7, now()) | ||
) STEP INTERVAL -1 DAY | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
VERSION 1 | ||
TOKEN "__ttl_7d_statuspage_get_endpoint_read_0234" READ | ||
|
||
NODE __ttl_7d_statuspage_get_0 | ||
SQL > | ||
|
||
% | ||
SELECT | ||
toDateTime(cronTimestamp / 1000, 'UTC') AS day, | ||
-- only for debugging purposes | ||
toTimezone(day, {{ String(timezone, 'Europe/London') }}) as with_timezone, | ||
toStartOfDay(with_timezone) as start_of_day, | ||
statusCode | ||
-- latency | ||
FROM __ttl_7d_mv | ||
WHERE monitorId = {{ String(monitorId, '4') }} | ||
|
||
|
||
|
||
NODE __ttl_7d_statuspage_get_1 | ||
SQL > | ||
|
||
% | ||
SELECT | ||
start_of_day as day, | ||
count() AS count, | ||
count(multiIf((statusCode >= 200) AND (statusCode <= 299), 1, NULL)) AS ok | ||
FROM __ttl_7d_statuspage_get_0 | ||
GROUP BY start_of_day | ||
ORDER BY start_of_day DESC | ||
WITH FILL | ||
FROM | ||
toStartOfDay(toTimezone(now(), {{ String(timezone, 'Europe/London') }})) | ||
TO toStartOfDay( | ||
toTimezone(date_sub(DAY, 46, now()), {{ String(timezone, 'Europe/London') }}) | ||
) STEP INTERVAL -1 DAY | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
VERSION 0 | ||
NODE dashboard_request_0 | ||
SQL > | ||
|
||
% | ||
SELECT * FROM monitor_request_count_7d_mv | ||
WHERE monitorId = {{ String(monitorId, '1') }} | ||
{% if defined(url) %} AND url = {{ String(url) }} {% end %} | ||
|
||
|
||
|
||
NODE dashboard_request_1 | ||
SQL > | ||
|
||
SELECT * FROM dashboard_request_0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
VERSION 0 | ||
NODE external_status_0 | ||
SQL > | ||
|
||
% | ||
SELECT * | ||
FROM external_status | ||
WHERE name = {{ String(name, 'OpenAI') }} | ||
ORDER BY fetched_at DESC | ||
LIMIT {{ Int16(limit, 10000) }} | ||
|
||
|