Skip to content

Commit 04392a4

Browse files
authored
Merge pull request #38 from tinybirdco/parameterize02
parameterize
2 parents 3bbc4fa + 0a6f521 commit 04392a4

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

tinybird/endpoints/ingestion.pipe

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ DESCRIPTION >
2121
for a tinybird organization, grouped by workspace_id, event_type and pipe name
2222
event_type can be 'append', 'append-hfi', 'append-kafka', 'append-dynamodb', 'replace', 'populateview', 'copy'
2323
Use from_datetime to get metrics since a date time, otherwise it returns last 5 minutes, except ingestion totals, which always sums all values
24+
In the response each metric has a description of what it means in the help column
25+
The format is compatible with Prometheus
2426

2527
NODE ingestion_totals
2628
SQL >

tinybird/endpoints/jobs.pipe

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
TOKEN "jobs_endpoint_read" READ
22

3+
DESCRIPTION >
4+
Returns ingestion metrics:
5+
jobs_total
6+
jobs_duration_avg
7+
jobs_duration_p99
8+
for a tinybird organization, grouped by workspace_id, job_type and status
9+
job_type can be copy, populate, import, gcs_sync, s3_sync, delete
10+
Use from_datetime to get metrics since a date time, otherwise it returns last 48 hours
11+
In the response each metric has a description of what it means in the help column
12+
The format is compatible with Prometheus
13+
314
NODE jobs_stats
415
SQL >
5-
16+
%
617
SELECT
718
workspace_id,
819
job_type,
@@ -12,7 +23,11 @@ SQL >
1223
quantile(0.99)
1324
(date_diff('seconds', created_at, updated_at)) as p99_duration
1425
FROM organization.jobs_log as stats
15-
where created_at > now() - interval 48 hours
26+
{% if defined(from_datetime) %}
27+
WHERE created_at >= toDateTime({{DateTime(from_datetime, description="timestamp >= from_datetime. Format YYYY-mm-DD HH:MM:ss")}})
28+
{% else %}
29+
where created_at > now() - interval 48 hours
30+
{% end %}
1631
group by workspace_id, job_type, status
1732

1833

tinybird/endpoints/organization_metrics.pipe

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
TOKEN "organization_metrics_endpoint_read" READ
22

3+
DESCRIPTION >
4+
returns metrics from ingestion, storage, jobs and requests pipes
5+
Use from_datetime to get metrics since a date time, except totals which always sums all values
6+
In the response each metric has a description of what it means in the help column
7+
The labels column, contains the columns by which the metrics are grouped by, including the workspace name
8+
The format is compatible with Prometheus
9+
310
NODE organization_metrics_union
411
SQL >
512

tinybird/endpoints/requests.pipe

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
TOKEN "requests_endpoint_read" READ
22

3+
DESCRIPTION >
4+
Returns requests to pipe endpoints metrics:
5+
requests_views_total
6+
requests_errors_total
7+
requests_read_rows_total
8+
requests_read_bytes_total
9+
requests_latency_avg_5m
10+
requests_latency_p90_5m
11+
requests_latency_p95_5m
12+
requests_latency_p99_5m
13+
requests_cpu_time_avg_5m
14+
requests_cpu_time_p90_5m
15+
requests_cpu_time_p95_5m
16+
requests_cpu_time_p99_5m
17+
for a tinybird organization, grouped by workspace_id and pipe name
18+
Use from_datetime to get metrics since a date time, otherwise it returns last 5 minutes, except requests totals, which always sums all values
19+
In the response each metric has a description of what it means in the help column
20+
The format is compatible with Prometheus
21+
322
NODE requests_totals
423
SQL >
524

@@ -17,7 +36,7 @@ SQL >
1736

1837
NODE requests_5m
1938
SQL >
20-
39+
%
2140
SELECT
2241
workspace_id,
2342
pipe_name,
@@ -30,7 +49,11 @@ SQL >
3049
quantile(0.95)(cpu_time) as cpu_time_p95,
3150
quantile(0.99)(cpu_time) as cpu_time_p99
3251
FROM organization.pipe_stats_rt
33-
where start_datetime > now() - interval 5 minutes
52+
{% if defined(from_datetime) %}
53+
WHERE start_datetime >= toDateTime({{DateTime(from_datetime, description="timestamp >= from_datetime. Format YYYY-mm-DD HH:MM:ss")}})
54+
{% else %}
55+
WHERE start_datetime >= now() - INTERVAL 5 MINUTE
56+
{% end %}
3457
group by workspace_id, pipe_name
3558

3659

tinybird/endpoints/storage.pipe

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
TOKEN "storage_endpoint_read" READ
22

3+
DESCRIPTION >
4+
Returns storage metrics:
5+
storage_rows
6+
storage_bytes
7+
storage_rows_quarantine
8+
storage_bytes_quarantine
9+
for a tinybird organization, grouped by workspace_id and datasource name
10+
In the response each metric has a description of what it means in the help column
11+
The format is compatible with Prometheus
12+
313
NODE storage_stats
414
SQL >
515

0 commit comments

Comments
 (0)