mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-14 01:02:55 +00:00
* feat: initial implement for promql subquery Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * impl and test Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * refactor Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * fix clippy Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
66 lines
2.2 KiB
Plaintext
66 lines
2.2 KiB
Plaintext
create table metric_total (
|
|
ts timestamp time index,
|
|
val double,
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into metric_total values
|
|
(0, 1),
|
|
(10000, 2);
|
|
|
|
Affected Rows: 2
|
|
|
|
tql eval (10, 10, '1s') sum_over_time(metric_total[50s:10s]);
|
|
|
|
+---------------------+----------------------------------+
|
|
| ts | prom_sum_over_time(ts_range,val) |
|
|
+---------------------+----------------------------------+
|
|
| 1970-01-01T00:00:10 | 3.0 |
|
|
+---------------------+----------------------------------+
|
|
|
|
tql eval (10, 10, '1s') sum_over_time(metric_total[50s:5s]);
|
|
|
|
+---------------------+----------------------------------+
|
|
| ts | prom_sum_over_time(ts_range,val) |
|
|
+---------------------+----------------------------------+
|
|
| 1970-01-01T00:00:10 | 4.0 |
|
|
+---------------------+----------------------------------+
|
|
|
|
tql eval (300, 300, '1s') sum_over_time(metric_total[50s:10s]);
|
|
|
|
+---------------------+----------------------------------+
|
|
| ts | prom_sum_over_time(ts_range,val) |
|
|
+---------------------+----------------------------------+
|
|
| 1970-01-01T00:05:00 | 10.0 |
|
|
+---------------------+----------------------------------+
|
|
|
|
tql eval (359, 359, '1s') sum_over_time(metric_total[60s:10s]);
|
|
|
|
+---------------------+----------------------------------+
|
|
| ts | prom_sum_over_time(ts_range,val) |
|
|
+---------------------+----------------------------------+
|
|
| 1970-01-01T00:05:59 | 2.0 |
|
|
+---------------------+----------------------------------+
|
|
|
|
tql eval (10, 10, '1s') rate(metric_total[20s:10s]);
|
|
|
|
+---------------------+----------------------------+
|
|
| ts | prom_rate(ts_range,val,ts) |
|
|
+---------------------+----------------------------+
|
|
| 1970-01-01T00:00:10 | 0.1 |
|
|
+---------------------+----------------------------+
|
|
|
|
tql eval (20, 20, '1s') rate(metric_total[20s:5s]);
|
|
|
|
+---------------------+----------------------------+
|
|
| ts | prom_rate(ts_range,val,ts) |
|
|
+---------------------+----------------------------+
|
|
| 1970-01-01T00:00:20 | 0.06666666666666667 |
|
|
+---------------------+----------------------------+
|
|
|
|
drop table metric_total;
|
|
|
|
Affected Rows: 0
|
|
|