mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-10-29 23:16:57 +00:00
feat: support PromQL operations over the same metric (#3124)
* update sqlness result Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update ut cases Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * remove deadcode Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -26,3 +26,30 @@ tql eval (0, 30, '10s'), data{__field__="val1"} + data{__field__="val2"};
|
||||
tql eval (0, 30, '10s'), data{__field__="val1", __field__="val2"} + data{__field__="val2", __field__="val3"};
|
||||
|
||||
drop table data;
|
||||
|
||||
create table host_cpu_seconds_total (
|
||||
ts timestamp time index,
|
||||
val double,
|
||||
host string,
|
||||
`mode` string,
|
||||
primary key (host, `mode`)
|
||||
);
|
||||
|
||||
insert into host_cpu_seconds_total values
|
||||
(0, 0.1, 'host1', 'idle'),
|
||||
(0, 0.2, 'host1', 'user'),
|
||||
(0, 0.3, 'host1', 'system'),
|
||||
(10000, 0.4, 'host1', 'idle'),
|
||||
(10000, 0.5, 'host1', 'user'),
|
||||
(10000, 0.6, 'host1', 'system'),
|
||||
(20000, 0.2, 'host1', 'idle'),
|
||||
(20000, 0.3, 'host1', 'user'),
|
||||
(20000, 0.4, 'host1', 'system'),
|
||||
(30000, 0.5, 'host1', 'idle'),
|
||||
(30000, 0.6, 'host1', 'user'),
|
||||
(30000, 0.7, 'host1', 'system');
|
||||
|
||||
-- SQLNESS SORT_RESULT 3 1
|
||||
tql eval (0, 30, '10s') (sum by(host) (irate(host_cpu_seconds_total{mode!="idle"}[1m0s])) / sum by (host)((irate(host_cpu_seconds_total[1m0s])))) * 100;
|
||||
|
||||
drop table host_cpu_seconds_total;
|
||||
|
||||
Reference in New Issue
Block a user