diff --git a/packages/tinybird/datasources/mv__dns_status_60m__v0.datasource b/packages/tinybird/datasources/mv__dns_status_60m__v0.datasource new file mode 100644 index 000000000..d9cb8d762 --- /dev/null +++ b/packages/tinybird/datasources/mv__dns_status_60m__v0.datasource @@ -0,0 +1,14 @@ +# Data Source created from Pipe 'aggregate__dns_status_60m__v0' + +SCHEMA > + `time` DateTime('UTC'), + `monitorId` Int16, + `count` AggregateFunction(count), + `success` AggregateFunction(count, Nullable(UInt8)), + `error` AggregateFunction(count, Nullable(UInt8)), + `degraded` AggregateFunction(count, Nullable(UInt8)) + +ENGINE "AggregatingMergeTree" +ENGINE_PARTITION_KEY "toYYYYMM(time)" +ENGINE_SORTING_KEY "monitorId, time" +ENGINE_TTL "time + toIntervalDay(46)" diff --git a/packages/tinybird/datasources/mv__grpc_status_60m__v0.datasource b/packages/tinybird/datasources/mv__grpc_status_60m__v0.datasource new file mode 100644 index 000000000..be38d18a1 --- /dev/null +++ b/packages/tinybird/datasources/mv__grpc_status_60m__v0.datasource @@ -0,0 +1,14 @@ +# Data Source created from Pipe 'aggregate__grpc_status_60m__v0' + +SCHEMA > + `time` DateTime('UTC'), + `monitorId` Int32, + `count` AggregateFunction(count), + `success` AggregateFunction(count, Nullable(UInt8)), + `error` AggregateFunction(count, Nullable(UInt8)), + `degraded` AggregateFunction(count, Nullable(UInt8)) + +ENGINE "AggregatingMergeTree" +ENGINE_PARTITION_KEY "toYYYYMM(time)" +ENGINE_SORTING_KEY "monitorId, time" +ENGINE_TTL "time + toIntervalDay(46)" diff --git a/packages/tinybird/datasources/mv__http_status_60m__v0.datasource b/packages/tinybird/datasources/mv__http_status_60m__v0.datasource new file mode 100644 index 000000000..d3571779c --- /dev/null +++ b/packages/tinybird/datasources/mv__http_status_60m__v0.datasource @@ -0,0 +1,14 @@ +# Data Source created from Pipe 'aggregate__http_status_60m__v0' + +SCHEMA > + `time` DateTime('UTC'), + `monitorId` String, + `count` AggregateFunction(count), + `success` AggregateFunction(count, Nullable(UInt8)), + `error` AggregateFunction(count, Nullable(UInt8)), + `degraded` AggregateFunction(count, Nullable(UInt8)) + +ENGINE "AggregatingMergeTree" +ENGINE_PARTITION_KEY "toYYYYMM(time)" +ENGINE_SORTING_KEY "monitorId, time" +ENGINE_TTL "time + toIntervalDay(46)" diff --git a/packages/tinybird/datasources/mv__icmp_status_60m__v0.datasource b/packages/tinybird/datasources/mv__icmp_status_60m__v0.datasource new file mode 100644 index 000000000..6881189f5 --- /dev/null +++ b/packages/tinybird/datasources/mv__icmp_status_60m__v0.datasource @@ -0,0 +1,14 @@ +# Data Source created from Pipe 'aggregate__icmp_status_60m__v0' + +SCHEMA > + `time` DateTime('UTC'), + `monitorId` Int32, + `count` AggregateFunction(count), + `success` AggregateFunction(count, Nullable(UInt8)), + `error` AggregateFunction(count, Nullable(UInt8)), + `degraded` AggregateFunction(count, Nullable(UInt8)) + +ENGINE "AggregatingMergeTree" +ENGINE_PARTITION_KEY "toYYYYMM(time)" +ENGINE_SORTING_KEY "monitorId, time" +ENGINE_TTL "time + toIntervalDay(46)" diff --git a/packages/tinybird/datasources/mv__tcp_status_60m__v0.datasource b/packages/tinybird/datasources/mv__tcp_status_60m__v0.datasource new file mode 100644 index 000000000..c169c777e --- /dev/null +++ b/packages/tinybird/datasources/mv__tcp_status_60m__v0.datasource @@ -0,0 +1,14 @@ +# Data Source created from Pipe 'aggregate__tcp_status_60m__v0' + +SCHEMA > + `time` DateTime('UTC'), + `monitorId` Int32, + `count` AggregateFunction(count), + `success` AggregateFunction(count, Nullable(UInt8)), + `error` AggregateFunction(count, Nullable(UInt8)), + `degraded` AggregateFunction(count, Nullable(UInt8)) + +ENGINE "AggregatingMergeTree" +ENGINE_PARTITION_KEY "toYYYYMM(time)" +ENGINE_SORTING_KEY "monitorId, time" +ENGINE_TTL "time + toIntervalDay(46)" diff --git a/packages/tinybird/endpoints/endpoint__dns_status_60m__v0.pipe b/packages/tinybird/endpoints/endpoint__dns_status_60m__v0.pipe new file mode 100644 index 000000000..573964394 --- /dev/null +++ b/packages/tinybird/endpoints/endpoint__dns_status_60m__v0.pipe @@ -0,0 +1,19 @@ +NODE endpoint +SQL > + +% +SELECT + -- epoch ms of local midnight in the requested zone: an unambiguous instant, + -- unlike a zone-less "YYYY-MM-DD 00:00:00" string the client would misread as UTC + toUnixTimestamp(toStartOfDay(toTimeZone(time, {{ String(timezone, 'UTC') }}))) * 1000 AS day, + monitorId, + countMerge(count) AS count, + countMerge(success) AS ok, + countMerge(error) AS error, + countMerge(degraded) AS degraded +FROM mv__dns_status_60m__v0 +WHERE monitorId IN {{ Array(monitorIds, 'String', '1,666') }} +GROUP BY day, monitorId +ORDER BY day DESC + +TYPE endpoint diff --git a/packages/tinybird/endpoints/endpoint__grpc_status_60m__v0.pipe b/packages/tinybird/endpoints/endpoint__grpc_status_60m__v0.pipe new file mode 100644 index 000000000..3b8e297da --- /dev/null +++ b/packages/tinybird/endpoints/endpoint__grpc_status_60m__v0.pipe @@ -0,0 +1,19 @@ +NODE endpoint +SQL > + +% +SELECT + -- epoch ms of local midnight in the requested zone: an unambiguous instant, + -- unlike a zone-less "YYYY-MM-DD 00:00:00" string the client would misread as UTC + toUnixTimestamp(toStartOfDay(toTimeZone(time, {{ String(timezone, 'UTC') }}))) * 1000 AS day, + monitorId, + countMerge(count) AS count, + countMerge(success) AS ok, + countMerge(error) AS error, + countMerge(degraded) AS degraded +FROM mv__grpc_status_60m__v0 +WHERE monitorId IN {{ Array(monitorIds, 'String', '1,666') }} +GROUP BY day, monitorId +ORDER BY day DESC + +TYPE endpoint diff --git a/packages/tinybird/endpoints/endpoint__http_status_60m__v0.pipe b/packages/tinybird/endpoints/endpoint__http_status_60m__v0.pipe new file mode 100644 index 000000000..cfecddcfd --- /dev/null +++ b/packages/tinybird/endpoints/endpoint__http_status_60m__v0.pipe @@ -0,0 +1,19 @@ +NODE endpoint +SQL > + +% +SELECT + -- epoch ms of local midnight in the requested zone: an unambiguous instant, + -- unlike a zone-less "YYYY-MM-DD 00:00:00" string the client would misread as UTC + toUnixTimestamp(toStartOfDay(toTimeZone(time, {{ String(timezone, 'UTC') }}))) * 1000 AS day, + monitorId, + countMerge(count) AS count, + countMerge(success) AS ok, + countMerge(error) AS error, + countMerge(degraded) AS degraded +FROM mv__http_status_60m__v0 +WHERE monitorId IN {{ Array(monitorIds, 'String', '1,666') }} +GROUP BY day, monitorId +ORDER BY day DESC + +TYPE endpoint diff --git a/packages/tinybird/endpoints/endpoint__icmp_status_60m__v0.pipe b/packages/tinybird/endpoints/endpoint__icmp_status_60m__v0.pipe new file mode 100644 index 000000000..6ba14da90 --- /dev/null +++ b/packages/tinybird/endpoints/endpoint__icmp_status_60m__v0.pipe @@ -0,0 +1,19 @@ +NODE endpoint +SQL > + +% +SELECT + -- epoch ms of local midnight in the requested zone: an unambiguous instant, + -- unlike a zone-less "YYYY-MM-DD 00:00:00" string the client would misread as UTC + toUnixTimestamp(toStartOfDay(toTimeZone(time, {{ String(timezone, 'UTC') }}))) * 1000 AS day, + monitorId, + countMerge(count) AS count, + countMerge(success) AS ok, + countMerge(error) AS error, + countMerge(degraded) AS degraded +FROM mv__icmp_status_60m__v0 +WHERE monitorId IN {{ Array(monitorIds, 'String', '1,666') }} +GROUP BY day, monitorId +ORDER BY day DESC + +TYPE endpoint diff --git a/packages/tinybird/endpoints/endpoint__tcp_status_60m__v0.pipe b/packages/tinybird/endpoints/endpoint__tcp_status_60m__v0.pipe new file mode 100644 index 000000000..3f7e50df6 --- /dev/null +++ b/packages/tinybird/endpoints/endpoint__tcp_status_60m__v0.pipe @@ -0,0 +1,19 @@ +NODE endpoint +SQL > + +% +SELECT + -- epoch ms of local midnight in the requested zone: an unambiguous instant, + -- unlike a zone-less "YYYY-MM-DD 00:00:00" string the client would misread as UTC + toUnixTimestamp(toStartOfDay(toTimeZone(time, {{ String(timezone, 'UTC') }}))) * 1000 AS day, + monitorId, + countMerge(count) AS count, + countMerge(success) AS ok, + countMerge(error) AS error, + countMerge(degraded) AS degraded +FROM mv__tcp_status_60m__v0 +WHERE monitorId IN {{ Array(monitorIds, 'String', '1,666') }} +GROUP BY day, monitorId +ORDER BY day DESC + +TYPE endpoint diff --git a/packages/tinybird/materializations/aggregate__dns_status_60m__v0.pipe b/packages/tinybird/materializations/aggregate__dns_status_60m__v0.pipe new file mode 100644 index 000000000..4443d0dd9 --- /dev/null +++ b/packages/tinybird/materializations/aggregate__dns_status_60m__v0.pipe @@ -0,0 +1,17 @@ +NODE aggregate +SQL > + + SELECT + toStartOfHour(toTimeZone(fromUnixTimestamp64Milli(cronTimestamp), 'UTC')) AS time, + monitorId, + countState() AS count, + countState(if(requestStatus = 'success', 1, NULL)) AS success, + countState(if(requestStatus = 'error', 1, NULL)) AS error, + countState(if(requestStatus = 'degraded', 1, NULL)) AS degraded + FROM dns_response__v0 + GROUP BY + time, + monitorId + +TYPE materialized +DATASOURCE mv__dns_status_60m__v0 diff --git a/packages/tinybird/materializations/aggregate__grpc_status_60m__v0.pipe b/packages/tinybird/materializations/aggregate__grpc_status_60m__v0.pipe new file mode 100644 index 000000000..bb3a1dd55 --- /dev/null +++ b/packages/tinybird/materializations/aggregate__grpc_status_60m__v0.pipe @@ -0,0 +1,17 @@ +NODE aggregate +SQL > + + SELECT + toStartOfHour(toTimeZone(fromUnixTimestamp64Milli(cronTimestamp), 'UTC')) AS time, + monitorId, + countState() AS count, + countState(if(requestStatus = 'success', 1, NULL)) AS success, + countState(if(requestStatus = 'error', 1, NULL)) AS error, + countState(if(requestStatus = 'degraded', 1, NULL)) AS degraded + FROM grpc_response__v0 + GROUP BY + time, + monitorId + +TYPE materialized +DATASOURCE mv__grpc_status_60m__v0 diff --git a/packages/tinybird/materializations/aggregate__http_status_60m__v0.pipe b/packages/tinybird/materializations/aggregate__http_status_60m__v0.pipe new file mode 100644 index 000000000..618974ad2 --- /dev/null +++ b/packages/tinybird/materializations/aggregate__http_status_60m__v0.pipe @@ -0,0 +1,17 @@ +NODE aggregate +SQL > + + SELECT + toStartOfHour(toTimeZone(fromUnixTimestamp64Milli(cronTimestamp), 'UTC')) AS time, + monitorId, + countState() AS count, + countState(if(requestStatus = 'success', 1, NULL)) AS success, + countState(if(requestStatus = 'error', 1, NULL)) AS error, + countState(if(requestStatus = 'degraded', 1, NULL)) AS degraded + FROM ping_response__v8 + GROUP BY + time, + monitorId + +TYPE materialized +DATASOURCE mv__http_status_60m__v0 diff --git a/packages/tinybird/materializations/aggregate__icmp_status_60m__v0.pipe b/packages/tinybird/materializations/aggregate__icmp_status_60m__v0.pipe new file mode 100644 index 000000000..762926ab5 --- /dev/null +++ b/packages/tinybird/materializations/aggregate__icmp_status_60m__v0.pipe @@ -0,0 +1,17 @@ +NODE aggregate +SQL > + + SELECT + toStartOfHour(toTimeZone(fromUnixTimestamp64Milli(cronTimestamp), 'UTC')) AS time, + monitorId, + countState() AS count, + countState(if(requestStatus = 'success', 1, NULL)) AS success, + countState(if(requestStatus = 'error', 1, NULL)) AS error, + countState(if(requestStatus = 'degraded', 1, NULL)) AS degraded + FROM icmp_response__v0 + GROUP BY + time, + monitorId + +TYPE materialized +DATASOURCE mv__icmp_status_60m__v0 diff --git a/packages/tinybird/materializations/aggregate__tcp_status_60m__v0.pipe b/packages/tinybird/materializations/aggregate__tcp_status_60m__v0.pipe new file mode 100644 index 000000000..3629ff41b --- /dev/null +++ b/packages/tinybird/materializations/aggregate__tcp_status_60m__v0.pipe @@ -0,0 +1,17 @@ +NODE aggregate +SQL > + + SELECT + toStartOfHour(toTimeZone(fromUnixTimestamp64Milli(cronTimestamp), 'UTC')) AS time, + monitorId, + countState() AS count, + countState(if(requestStatus = 'success', 1, NULL)) AS success, + countState(if(requestStatus = 'error', 1, NULL)) AS error, + countState(if(requestStatus = 'degraded', 1, NULL)) AS degraded + FROM tcp_response__v0 + GROUP BY + time, + monitorId + +TYPE materialized +DATASOURCE mv__tcp_status_60m__v0 diff --git a/packages/tinybird/src/client.ts b/packages/tinybird/src/client.ts index 9acecf7b6..be2918e14 100644 --- a/packages/tinybird/src/client.ts +++ b/packages/tinybird/src/client.ts @@ -807,6 +807,30 @@ export class OSTinybird { }); } + /** + * Hourly status buckets grouped into days of `timezone` at read time. Returns + * the same columns as the 45d pipe; `day` arrives as epoch ms of the local + * midnight (an instant), not a zone-less date string. + */ + public get httpStatus60m() { + return this.tb.buildPipe({ + pipe: "endpoint__http_status_60m__v0", + parameters: z.object({ + monitorIds: z.string().array(), + timezone: z.string().prefault("UTC"), + }), + data: z.object({ + day: z.number().transform((ms) => new Date(ms).toISOString()), + count: z.number().prefault(0), + ok: z.number().prefault(0), + degraded: z.number().prefault(0), + error: z.number().prefault(0), + monitorId: z.string(), + }), + opts: { next: { revalidate: REVALIDATE } }, + }); + } + public get httpStatus45d() { return this.tb.buildPipe({ pipe: "endpoint__http_status_45d__v1", @@ -1374,6 +1398,25 @@ export class OSTinybird { }); } + public get tcpStatus60m() { + return this.tb.buildPipe({ + pipe: "endpoint__tcp_status_60m__v0", + parameters: z.object({ + monitorIds: z.string().array(), + timezone: z.string().prefault("UTC"), + }), + data: z.object({ + day: z.number().transform((ms) => new Date(ms).toISOString()), + count: z.number().prefault(0), + ok: z.number().prefault(0), + degraded: z.number().prefault(0), + error: z.number().prefault(0), + monitorId: z.coerce.string(), + }), + opts: { next: { revalidate: REVALIDATE } }, + }); + } + public get tcpStatus45d() { return this.tb.buildPipe({ pipe: "endpoint__tcp_status_45d__v1", @@ -1774,6 +1817,25 @@ export class OSTinybird { }); } + public get icmpStatus60m() { + return this.tb.buildPipe({ + pipe: "endpoint__icmp_status_60m__v0", + parameters: z.object({ + monitorIds: z.string().array(), + timezone: z.string().prefault("UTC"), + }), + data: z.object({ + day: z.number().transform((ms) => new Date(ms).toISOString()), + count: z.number().prefault(0), + ok: z.number().prefault(0), + degraded: z.number().prefault(0), + error: z.number().prefault(0), + monitorId: z.coerce.string(), + }), + opts: { next: { revalidate: REVALIDATE } }, + }); + } + public get icmpStatus45d() { return this.tb.buildPipe({ pipe: "endpoint__icmp_status_45d__v0", @@ -2245,6 +2307,25 @@ export class OSTinybird { }); } + public get grpcStatus60m() { + return this.tb.buildPipe({ + pipe: "endpoint__grpc_status_60m__v0", + parameters: z.object({ + monitorIds: z.string().array(), + timezone: z.string().prefault("UTC"), + }), + data: z.object({ + day: z.number().transform((ms) => new Date(ms).toISOString()), + count: z.number().prefault(0), + ok: z.number().prefault(0), + degraded: z.number().prefault(0), + error: z.number().prefault(0), + monitorId: z.coerce.string(), + }), + opts: { next: { revalidate: REVALIDATE } }, + }); + } + public get grpcStatus45d() { return this.tb.buildPipe({ pipe: "endpoint__grpc_status_45d__v0", @@ -3531,6 +3612,25 @@ export class OSTinybird { }); } + public get dnsStatus60m() { + return this.tb.buildPipe({ + pipe: "endpoint__dns_status_60m__v0", + parameters: z.object({ + monitorIds: z.string().array(), + timezone: z.string().prefault("UTC"), + }), + data: z.object({ + day: z.number().transform((ms) => new Date(ms).toISOString()), + count: z.number().prefault(0), + ok: z.number().prefault(0), + degraded: z.number().prefault(0), + error: z.number().prefault(0), + monitorId: z.coerce.string(), + }), + opts: { next: { revalidate: REVALIDATE } }, + }); + } + public get dnsStatus45d() { return this.tb.buildPipe({ pipe: "endpoint__dns_status_45d__v0",