mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-11-26 12:44:10 +00:00
* fix(promql): derive vector matching result labels and reject ambiguous matchings A vector-vector binary operation projected one operand's whole tag set and inner-joined without any cardinality check, so `on()`/`ignoring()` did not reduce the result labels, `group_left`/`group_right` changed nothing, and a non-unique match group produced a cross product that PromQL cannot represent. Result labels now follow Prometheus `resultMetric`: `on(...)` keeps the matching labels, `ignoring(...)` drops them, and a group modifier keeps the many side's labels plus the `group_x(...)` labels taken from the one side. A label the one side does not carry is deleted from the result. The reduced label set no longer identifies the operand series, so `__tsid` is dropped from the context on this path. Cardinality is enforced with a `count(1) OVER (PARTITION BY match keys, ts)` window and a scalar UDF that fails the query on a repeated group: on the one side before the join, and on the result labels after it, matching where Prometheus raises each of its three errors. Series are unique by their whole tag set, so the window is only planted when the match keys drop a tag; plain arithmetic and `on(<all tags>)` plan exactly as before. Closes #9207, closes #9208, closes #9209. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * perf(promql): keep __tsid when the result labels are an operand's whole tag set Deriving the result labels dropped `__tsid` from the context unconditionally, so an enclosing operation fell back to joining on the tag columns even where the column still identified the result series. Keep it when every result label comes from one operand and covers that operand's whole tag set: no other operand value reaches the labels, and the matching gives each of its rows a single partner, so its `__tsid` is still one per result series. That is the common `on(<all tags>)` and bare `group_left` shape; a matching that actually drops a tag still clears it. The column is re-qualified as the result's own, which is how the enclosing expression and the context look it up. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): keep the match group count column unambiguous The cardinality check aliased its row count to a fixed `__promql_match_group_count`. An operand carrying a label of that name made the window output two fields with the same name, and planning failed with "Schema contains qualified field name collide_right.__promql_match_group_count and unqualified field name __promql_match_group_count which would be ambiguous". Pick a name the operand does not already have, the way the `or` operator allocates its match key columns. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): cover a match group spread over several regions The cardinality check runs above the merge of the region scans, so it counts a match group globally. Nothing pinned that: every table in these cases holds a single region, and a check evaluated per region would pass them all. Partition the operand on a column outside the match keys, which puts the two series of one match group in different regions, and assert both the pre-join and the post-join check still reject it. The case runs in the distributed environment too, where the regions sit on different datanodes. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * fix(promql): group an outer aggregate on the labels the operand kept `by`/`without` planning topped up a missing grouping column by walking down to the table scan and re-projecting it. That is right for a column the scan pruned for efficiency, but the labels a matching modifier deletes are also absent from the operand's output, and they were restored the same way: sum without(host) (a / on(host) b) `on(host)` leaves the operand with `host` alone, so the sum covers everything and Prometheus answers `{} 10`. Instead `device` came back from the scan under `a` and split the result into `{device="d1"} 5` and `{device="d2"} 5`. Same for `sum by(device)` of that operand, which has no `device` to group on at all. Take the grouping labels from the operand's own label set rather than from the row keys of the scan beneath it. A label pruned from the plan is still in that set and still gets restored; a label the operand dropped is not. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * refactor(promql): drop the unreachable aggregation tag top-up `by`/`without` planning could restore a grouping column that the plan no longer carried by rewriting the scan underneath it. Once the grouping labels come from the operand's own label set, there is nothing left for it to restore: a scan projects every label of `ctx.tag_columns` (`scan_tag_columns` only ever adds matcher columns to that set), so a label in the set is always in the schema. Stubbing the rewriter to a no-op passed the whole sqlness suite, in both the standalone and the distributed environment. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * test(promql): drop cases that guarded the removed tag top-up Three plain selector aggregates were there to show that restoring a pruned grouping column still worked. With the restore gone they only repeat what the aggregate cases already cover. Also fix a comment that still said the metric engine scan prunes tag columns: it projects every label of the operand. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> * docs(promql): note the duplicate a propagated matcher hides A matcher copied onto the one-side operand removes groups without a partner before the cardinality check sees them, so a duplicate in such a group is not reported. Prometheus checks every group of the one side and fails the query. Signed-off-by: Dennis Zhuang <killme2008@gmail.com> --------- Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
839 lines
45 KiB
Plaintext
839 lines
45 KiB
Plaintext
-- from promql/testdata/operators.test
|
|
-- cases related to AND/OR/UNLESS
|
|
-- group_left() and group_right() are not included
|
|
create table http_requests (
|
|
ts timestamp time index,
|
|
job string,
|
|
instance string,
|
|
g string, -- for `group`
|
|
greptime_value double,
|
|
primary key (job, instance, g)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into http_requests values
|
|
(3000000, "api", "0", "production", 100),
|
|
(3000000, "api", "1", "production", 200),
|
|
(3000000, "api", "0", "canary", 300),
|
|
(3000000, "api", "1", "canary", 400),
|
|
(3000000, "app", "0", "production", 500),
|
|
(3000000, "app", "1", "production", 600),
|
|
(3000000, "app", "0", "canary", 700),
|
|
(3000000, "app", "1", "canary", 800);
|
|
|
|
Affected Rows: 8
|
|
|
|
-- empty metric
|
|
create table cpu_count(ts timestamp time index, greptime_value double);
|
|
|
|
Affected Rows: 0
|
|
|
|
create table vector_matching_a(
|
|
ts timestamp time index,
|
|
l string primary key,
|
|
greptime_value double,
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into vector_matching_a values
|
|
(3000000, "x", 10);
|
|
|
|
Affected Rows: 1
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} and http_requests{instance="0"}
|
|
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
|
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} and http_requests{instance="0"};
|
|
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| 1970-01-01T00:50:00 | api | 0 | canary | 300.0 |
|
|
| 1970-01-01T00:50:00 | app | 0 | canary | 700.0 |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) and http_requests{instance="0"}
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and http_requests{instance="0"};
|
|
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| job | instance | g | ts | greptime_value + Float64(1) |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| api | 0 | canary | 1970-01-01T00:50:00 | 301.0 |
|
|
| app | 0 | canary | 1970-01-01T00:50:00 | 701.0 |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) and on(instance, job) http_requests{instance="0", group="production"}
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and on(instance, job) http_requests{instance="0", g="production"};
|
|
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| job | instance | g | ts | greptime_value + Float64(1) |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| api | 0 | canary | 1970-01-01T00:50:00 | 301.0 |
|
|
| app | 0 | canary | 1970-01-01T00:50:00 | 701.0 |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) and on(instance) http_requests{instance="0", group="production"}
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and on(instance) http_requests{instance="0", g="production"};
|
|
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| job | instance | g | ts | greptime_value + Float64(1) |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| api | 0 | canary | 1970-01-01T00:50:00 | 301.0 |
|
|
| app | 0 | canary | 1970-01-01T00:50:00 | 701.0 |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) and ignoring(group) http_requests{instance="0", group="production"}
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and ignoring(g) http_requests{instance="0", g="production"};
|
|
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| job | instance | g | ts | greptime_value + Float64(1) |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| api | 0 | canary | 1970-01-01T00:50:00 | 301.0 |
|
|
| app | 0 | canary | 1970-01-01T00:50:00 | 701.0 |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) and ignoring(group, job) http_requests{instance="0", group="production"}
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) and ignoring(g, job) http_requests{instance="0", g="production"};
|
|
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| job | instance | g | ts | greptime_value + Float64(1) |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
| api | 0 | canary | 1970-01-01T00:50:00 | 301.0 |
|
|
| app | 0 | canary | 1970-01-01T00:50:00 | 701.0 |
|
|
+-----+----------+--------+---------------------+-----------------------------+
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} or http_requests{group="production"}
|
|
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
|
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
|
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
|
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
|
-- http_requests{group="production", instance="0", job="api-server"} 100
|
|
-- http_requests{group="production", instance="0", job="app-server"} 500
|
|
-- http_requests{group="production", instance="1", job="api-server"} 200
|
|
-- http_requests{group="production", instance="1", job="app-server"} 600
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} or http_requests{g="production"};
|
|
|
|
+---------------------+------------+----------------+----------+-----+
|
|
| ts | g | greptime_value | instance | job |
|
|
+---------------------+------------+----------------+----------+-----+
|
|
| 1970-01-01T00:50:00 | canary | 300.0 | 0 | api |
|
|
| 1970-01-01T00:50:00 | canary | 400.0 | 1 | api |
|
|
| 1970-01-01T00:50:00 | canary | 700.0 | 0 | app |
|
|
| 1970-01-01T00:50:00 | canary | 800.0 | 1 | app |
|
|
| 1970-01-01T00:50:00 | production | 100.0 | 0 | api |
|
|
| 1970-01-01T00:50:00 | production | 200.0 | 1 | api |
|
|
| 1970-01-01T00:50:00 | production | 500.0 | 0 | app |
|
|
| 1970-01-01T00:50:00 | production | 600.0 | 1 | app |
|
|
+---------------------+------------+----------------+----------+-----+
|
|
|
|
-- # On overlap the rhs samples must be dropped.
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) or http_requests{instance="1"}
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- {group="canary", instance="1", job="api-server"} 401
|
|
-- {group="canary", instance="1", job="app-server"} 801
|
|
-- http_requests{group="production", instance="1", job="api-server"} 200
|
|
-- http_requests{group="production", instance="1", job="app-server"} 600
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) or http_requests{instance="1"};
|
|
|
|
+---------------------+------------+-----------------------------+----------+-----+
|
|
| ts | g | greptime_value + Float64(1) | instance | job |
|
|
+---------------------+------------+-----------------------------+----------+-----+
|
|
| 1970-01-01T00:50:00 | canary | 301.0 | 0 | api |
|
|
| 1970-01-01T00:50:00 | canary | 401.0 | 1 | api |
|
|
| 1970-01-01T00:50:00 | canary | 701.0 | 0 | app |
|
|
| 1970-01-01T00:50:00 | canary | 801.0 | 1 | app |
|
|
| 1970-01-01T00:50:00 | production | 200.0 | 1 | api |
|
|
| 1970-01-01T00:50:00 | production | 600.0 | 1 | app |
|
|
+---------------------+------------+-----------------------------+----------+-----+
|
|
|
|
-- # Matching only on instance excludes everything that has instance=0/1 but includes
|
|
-- # entries without the instance label.
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) or on(instance) (http_requests or cpu_count or vector_matching_a)
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- {group="canary", instance="1", job="api-server"} 401
|
|
-- {group="canary", instance="1", job="app-server"} 801
|
|
-- vector_matching_a{l="x"} 10
|
|
-- vector_matching_a{l="y"} 20
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) or on(instance) (http_requests or cpu_count or vector_matching_a);
|
|
|
|
+---------------------+--------+-----------------------------+----------+-----+---+
|
|
| ts | g | greptime_value + Float64(1) | instance | job | l |
|
|
+---------------------+--------+-----------------------------+----------+-----+---+
|
|
| 1970-01-01T00:50:00 | | 10.0 | | | x |
|
|
| 1970-01-01T00:50:00 | canary | 301.0 | 0 | api | |
|
|
| 1970-01-01T00:50:00 | canary | 401.0 | 1 | api | |
|
|
| 1970-01-01T00:50:00 | canary | 701.0 | 0 | app | |
|
|
| 1970-01-01T00:50:00 | canary | 801.0 | 1 | app | |
|
|
+---------------------+--------+-----------------------------+----------+-----+---+
|
|
|
|
-- eval instant at 50m (http_requests{group="canary"} + 1) or ignoring(l, group, job) (http_requests or cpu_count or vector_matching_a)
|
|
-- {group="canary", instance="0", job="api-server"} 301
|
|
-- {group="canary", instance="0", job="app-server"} 701
|
|
-- {group="canary", instance="1", job="api-server"} 401
|
|
-- {group="canary", instance="1", job="app-server"} 801
|
|
-- vector_matching_a{l="x"} 10
|
|
-- vector_matching_a{l="y"} 20
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') (http_requests{g="canary"} + 1) or ignoring(l, g, job) (http_requests or cpu_count or vector_matching_a);
|
|
|
|
+---------------------+--------+-----------------------------+----------+-----+---+
|
|
| ts | g | greptime_value + Float64(1) | instance | job | l |
|
|
+---------------------+--------+-----------------------------+----------+-----+---+
|
|
| 1970-01-01T00:50:00 | | 10.0 | | | x |
|
|
| 1970-01-01T00:50:00 | canary | 301.0 | 0 | api | |
|
|
| 1970-01-01T00:50:00 | canary | 401.0 | 1 | api | |
|
|
| 1970-01-01T00:50:00 | canary | 701.0 | 0 | app | |
|
|
| 1970-01-01T00:50:00 | canary | 801.0 | 1 | app | |
|
|
+---------------------+--------+-----------------------------+----------+-----+---+
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} unless http_requests{instance="0"}
|
|
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
|
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless http_requests{instance="0"};
|
|
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| 1970-01-01T00:50:00 | api | 1 | canary | 400.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | canary | 800.0 |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} unless on(job) http_requests{instance="0"}
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless on(job) http_requests{instance="0"};
|
|
|
|
+----+-----+----------+---+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+----+-----+----------+---+----------------+
|
|
+----+-----+----------+---+----------------+
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} unless on(job, instance) http_requests{instance="0"}
|
|
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
|
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless on(job, instance) http_requests{instance="0"};
|
|
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| 1970-01-01T00:50:00 | api | 1 | canary | 400.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | canary | 800.0 |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} unless ignoring(group, instance) http_requests{instance="0"}
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless ignoring(g, instance) http_requests{instance="0"};
|
|
|
|
+----+-----+----------+---+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+----+-----+----------+---+----------------+
|
|
+----+-----+----------+---+----------------+
|
|
|
|
-- eval instant at 50m http_requests{group="canary"} unless ignoring(group) http_requests{instance="0"}
|
|
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
|
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests{g="canary"} unless ignoring(g) http_requests{instance="0"};
|
|
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
| 1970-01-01T00:50:00 | api | 1 | canary | 400.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | canary | 800.0 |
|
|
+---------------------+-----+----------+--------+----------------+
|
|
|
|
-- # https://github.com/prometheus/prometheus/issues/1489
|
|
-- eval instant at 50m http_requests AND ON (dummy) vector(1)
|
|
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
|
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
|
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
|
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
|
-- http_requests{group="production", instance="0", job="api-server"} 100
|
|
-- http_requests{group="production", instance="0", job="app-server"} 500
|
|
-- http_requests{group="production", instance="1", job="api-server"} 200
|
|
-- http_requests{group="production", instance="1", job="app-server"} 600
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests AND ON (dummy) vector(1);
|
|
|
|
+---------------------+-----+----------+------------+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+---------------------+-----+----------+------------+----------------+
|
|
| 1970-01-01T00:50:00 | api | 0 | canary | 300.0 |
|
|
| 1970-01-01T00:50:00 | api | 0 | production | 100.0 |
|
|
| 1970-01-01T00:50:00 | api | 1 | canary | 400.0 |
|
|
| 1970-01-01T00:50:00 | api | 1 | production | 200.0 |
|
|
| 1970-01-01T00:50:00 | app | 0 | canary | 700.0 |
|
|
| 1970-01-01T00:50:00 | app | 0 | production | 500.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | canary | 800.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | production | 600.0 |
|
|
+---------------------+-----+----------+------------+----------------+
|
|
|
|
-- eval instant at 50m http_requests AND IGNORING (group, instance, job) vector(1)
|
|
-- http_requests{group="canary", instance="0", job="api-server"} 300
|
|
-- http_requests{group="canary", instance="0", job="app-server"} 700
|
|
-- http_requests{group="canary", instance="1", job="api-server"} 400
|
|
-- http_requests{group="canary", instance="1", job="app-server"} 800
|
|
-- http_requests{group="production", instance="0", job="api-server"} 100
|
|
-- http_requests{group="production", instance="0", job="app-server"} 500
|
|
-- http_requests{group="production", instance="1", job="api-server"} 200
|
|
-- http_requests{group="production", instance="1", job="app-server"} 600
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') http_requests AND IGNORING (g, instance, job) vector(1);
|
|
|
|
+---------------------+-----+----------+------------+----------------+
|
|
| ts | job | instance | g | greptime_value |
|
|
+---------------------+-----+----------+------------+----------------+
|
|
| 1970-01-01T00:50:00 | api | 0 | canary | 300.0 |
|
|
| 1970-01-01T00:50:00 | api | 0 | production | 100.0 |
|
|
| 1970-01-01T00:50:00 | api | 1 | canary | 400.0 |
|
|
| 1970-01-01T00:50:00 | api | 1 | production | 200.0 |
|
|
| 1970-01-01T00:50:00 | app | 0 | canary | 700.0 |
|
|
| 1970-01-01T00:50:00 | app | 0 | production | 500.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | canary | 800.0 |
|
|
| 1970-01-01T00:50:00 | app | 1 | production | 600.0 |
|
|
+---------------------+-----+----------+------------+----------------+
|
|
|
|
-- https://github.com/GreptimeTeam/greptimedb/issues/5392
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3000, 3000, '1s') vector(1) * http_requests;
|
|
|
|
+-----+----------+------------+---------------------+------------------------------------------------+
|
|
| job | instance | g | ts | .greptime_value * http_requests.greptime_value |
|
|
+-----+----------+------------+---------------------+------------------------------------------------+
|
|
| api | 0 | canary | 1970-01-01T00:50:00 | 300.0 |
|
|
| api | 0 | production | 1970-01-01T00:50:00 | 100.0 |
|
|
| api | 1 | canary | 1970-01-01T00:50:00 | 400.0 |
|
|
| api | 1 | production | 1970-01-01T00:50:00 | 200.0 |
|
|
| app | 0 | canary | 1970-01-01T00:50:00 | 700.0 |
|
|
| app | 0 | production | 1970-01-01T00:50:00 | 500.0 |
|
|
| app | 1 | canary | 1970-01-01T00:50:00 | 800.0 |
|
|
| app | 1 | production | 1970-01-01T00:50:00 | 600.0 |
|
|
+-----+----------+------------+---------------------+------------------------------------------------+
|
|
|
|
drop table http_requests;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table cpu_count;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table vector_matching_a;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- the following cases are not from Prometheus.
|
|
create table t1 (ts timestamp time index, job string primary key, greptime_value double);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into t1 values (0, "a", 1.0), (500000, "b", 2.0), (1000000, "a", 3.0), (1500000, "c", 4.0);
|
|
|
|
Affected Rows: 4
|
|
|
|
create table t2 (ts timestamp time index, greptime_value double);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into t2 values (0, 0), (300000, 0), (600000, 0), (900000, 0), (1200000, 0), (1500000, 0), (1800000, 0);
|
|
|
|
Affected Rows: 7
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') t1 or t2;
|
|
|
|
+---------------------+----------------+-----+
|
|
| ts | greptime_value | job |
|
|
+---------------------+----------------+-----+
|
|
| 1970-01-01T00:00:00 | 0.0 | |
|
|
| 1970-01-01T00:00:00 | 1.0 | a |
|
|
| 1970-01-01T00:06:40 | 0.0 | |
|
|
| 1970-01-01T00:13:20 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 3.0 | a |
|
|
| 1970-01-01T00:26:40 | 0.0 | |
|
|
| 1970-01-01T00:26:40 | 4.0 | c |
|
|
| 1970-01-01T00:33:20 | 0.0 | |
|
|
+---------------------+----------------+-----+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') t1 or on () t2;
|
|
|
|
+---------------------+----------------+-----+
|
|
| ts | greptime_value | job |
|
|
+---------------------+----------------+-----+
|
|
| 1970-01-01T00:00:00 | 1.0 | a |
|
|
| 1970-01-01T00:06:40 | 0.0 | |
|
|
| 1970-01-01T00:13:20 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 3.0 | a |
|
|
| 1970-01-01T00:26:40 | 4.0 | c |
|
|
| 1970-01-01T00:33:20 | 0.0 | |
|
|
+---------------------+----------------+-----+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') t1 or on (job) t2;
|
|
|
|
+---------------------+----------------+-----+
|
|
| ts | greptime_value | job |
|
|
+---------------------+----------------+-----+
|
|
| 1970-01-01T00:00:00 | 0.0 | |
|
|
| 1970-01-01T00:00:00 | 1.0 | a |
|
|
| 1970-01-01T00:06:40 | 0.0 | |
|
|
| 1970-01-01T00:13:20 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 3.0 | a |
|
|
| 1970-01-01T00:26:40 | 0.0 | |
|
|
| 1970-01-01T00:26:40 | 4.0 | c |
|
|
| 1970-01-01T00:33:20 | 0.0 | |
|
|
+---------------------+----------------+-----+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') t2 or t1;
|
|
|
|
+---------------------+----------------+-----+
|
|
| ts | greptime_value | job |
|
|
+---------------------+----------------+-----+
|
|
| 1970-01-01T00:00:00 | 0.0 | |
|
|
| 1970-01-01T00:00:00 | 1.0 | a |
|
|
| 1970-01-01T00:06:40 | 0.0 | |
|
|
| 1970-01-01T00:13:20 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 3.0 | a |
|
|
| 1970-01-01T00:26:40 | 0.0 | |
|
|
| 1970-01-01T00:26:40 | 4.0 | c |
|
|
| 1970-01-01T00:33:20 | 0.0 | |
|
|
+---------------------+----------------+-----+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') t2 or on () t1;
|
|
|
|
+---------------------+----------------+-----+
|
|
| ts | greptime_value | job |
|
|
+---------------------+----------------+-----+
|
|
| 1970-01-01T00:00:00 | 0.0 | |
|
|
| 1970-01-01T00:06:40 | 0.0 | |
|
|
| 1970-01-01T00:13:20 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 0.0 | |
|
|
| 1970-01-01T00:26:40 | 0.0 | |
|
|
| 1970-01-01T00:33:20 | 0.0 | |
|
|
+---------------------+----------------+-----+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') t2 or on(job) t1;
|
|
|
|
+---------------------+----------------+-----+
|
|
| ts | greptime_value | job |
|
|
+---------------------+----------------+-----+
|
|
| 1970-01-01T00:00:00 | 0.0 | |
|
|
| 1970-01-01T00:00:00 | 1.0 | a |
|
|
| 1970-01-01T00:06:40 | 0.0 | |
|
|
| 1970-01-01T00:13:20 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 0.0 | |
|
|
| 1970-01-01T00:20:00 | 3.0 | a |
|
|
| 1970-01-01T00:26:40 | 0.0 | |
|
|
| 1970-01-01T00:26:40 | 4.0 | c |
|
|
| 1970-01-01T00:33:20 | 0.0 | |
|
|
+---------------------+----------------+-----+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') sum(t1{job="a"});
|
|
|
|
+---------------------+------------------------+
|
|
| ts | sum(t1.greptime_value) |
|
|
+---------------------+------------------------+
|
|
| 1970-01-01T00:00:00 | 1.0 |
|
|
| 1970-01-01T00:20:00 | 3.0 |
|
|
+---------------------+------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') sum(t1{job="a"}) - sum(t1{job="e"} or vector(1));
|
|
|
|
+---------------------+---------------------------------------------------------+
|
|
| ts | lhs.sum(t1.greptime_value) - rhs.sum(t1.greptime_value) |
|
|
+---------------------+---------------------------------------------------------+
|
|
| 1970-01-01T00:00:00 | 0.0 |
|
|
| 1970-01-01T00:20:00 | 2.0 |
|
|
+---------------------+---------------------------------------------------------+
|
|
|
|
drop table t1;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table t2;
|
|
|
|
Affected Rows: 0
|
|
|
|
create table stats_used_bytes (
|
|
ts timestamp time index,
|
|
namespace string,
|
|
greptime_value double,
|
|
primary key (namespace)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
create table stats_capacity_bytes (
|
|
ts timestamp time index,
|
|
namespace string,
|
|
greptime_value double,
|
|
primary key (namespace)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into stats_used_bytes values
|
|
(0, "namespace1", 1.0),
|
|
(0, "namespace2", 2.0),
|
|
(500000, "namespace1", 10.0),
|
|
(500000, "namespace2", 20.0),
|
|
(1000000, "namespace1", 25.0),
|
|
(1000000, "namespace2", 26.0);
|
|
|
|
Affected Rows: 6
|
|
|
|
insert into stats_capacity_bytes values
|
|
(0, "namespace1", 30.0),
|
|
(0, "namespace2", 30.0),
|
|
(500000, "namespace1", 30.0),
|
|
(500000, "namespace2", 30.0),
|
|
(1000000, "namespace1", 30.0),
|
|
(1000000, "namespace2", 30.0);
|
|
|
|
Affected Rows: 6
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') max by (namespace) (stats_used_bytes{namespace=~".+"}) / max by (namespace) (stats_capacity_bytes{namespace=~".+"}) >= (80 / 100);
|
|
|
|
+------------+---------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| namespace | ts | stats_used_bytes.max(stats_used_bytes.greptime_value) / stats_capacity_bytes.max(stats_capacity_bytes.greptime_value) |
|
|
+------------+---------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
| namespace1 | 1970-01-01T00:20:00 | 0.8333333333333334 |
|
|
| namespace2 | 1970-01-01T00:20:00 | 0.8666666666666667 |
|
|
+------------+---------------------+-----------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') max by (namespace) (stats_used_bytes{namespace=~".+"}) and (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100));
|
|
|
|
+------------+---------------------+--------------------------------------+
|
|
| namespace | ts | max(stats_used_bytes.greptime_value) |
|
|
+------------+---------------------+--------------------------------------+
|
|
| namespace1 | 1970-01-01T00:20:00 | 25.0 |
|
|
| namespace2 | 1970-01-01T00:20:00 | 26.0 |
|
|
+------------+---------------------+--------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') count(max by (namespace) (stats_used_bytes{namespace=~".+"}) and (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100))) or vector(0);
|
|
|
|
+---------------------+---------------------------------------------+
|
|
| ts | count(max(stats_used_bytes.greptime_value)) |
|
|
+---------------------+---------------------------------------------+
|
|
| 1970-01-01T00:00:00 | 0.0 |
|
|
| 1970-01-01T00:06:40 | 0.0 |
|
|
| 1970-01-01T00:13:20 | 0.0 |
|
|
| 1970-01-01T00:20:00 | 2.0 |
|
|
| 1970-01-01T00:26:40 | 0.0 |
|
|
| 1970-01-01T00:33:20 | 0.0 |
|
|
+---------------------+---------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') count(max by (namespace) (stats_used_bytes{namespace=~".+"}) and (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100)));
|
|
|
|
+---------------------+---------------------------------------------+
|
|
| ts | count(max(stats_used_bytes.greptime_value)) |
|
|
+---------------------+---------------------------------------------+
|
|
| 1970-01-01T00:20:00 | 2 |
|
|
+---------------------+---------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (0, 2000, '400') count(max by (namespace) (stats_used_bytes{namespace=~".+"}) unless (max by (namespace) (stats_used_bytes{namespace=~".+"}) / (max by (namespace) (stats_capacity_bytes{namespace=~".+"})) >= (80 / 100)));
|
|
|
|
+---------------------+---------------------------------------------+
|
|
| ts | count(max(stats_used_bytes.greptime_value)) |
|
|
+---------------------+---------------------------------------------+
|
|
| 1970-01-01T00:00:00 | 2 |
|
|
+---------------------+---------------------------------------------+
|
|
|
|
drop table stats_used_bytes;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table stats_capacity_bytes;
|
|
|
|
Affected Rows: 0
|
|
|
|
create table cache_hit (
|
|
ts timestamp time index,
|
|
job string,
|
|
greptime_value double,
|
|
primary key (job)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
create table cache_miss (
|
|
ts timestamp time index,
|
|
job string,
|
|
greptime_value double,
|
|
primary key (job)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into cache_hit values
|
|
(3000, "read", 1.0),
|
|
(3000, "write", 2.0),
|
|
(4000, "read", 3.0),
|
|
(4000, "write", 4.0);
|
|
|
|
Affected Rows: 4
|
|
|
|
insert into cache_miss values
|
|
(3000, "read", 1.0),
|
|
(3000, "write", 2.0),
|
|
(4000, "read", 1.0),
|
|
(4000, "write", 2.0);
|
|
|
|
Affected Rows: 4
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3, 4, '1s') cache_hit / (cache_miss + cache_hit);
|
|
|
|
+-------+---------------------+---------------------------------------------------------------------------------+
|
|
| job | ts | cache_hit.greptime_value / cache_miss.greptime_value + cache_hit.greptime_value |
|
|
+-------+---------------------+---------------------------------------------------------------------------------+
|
|
| read | 1970-01-01T00:00:03 | 0.5 |
|
|
| read | 1970-01-01T00:00:04 | 0.75 |
|
|
| write | 1970-01-01T00:00:03 | 0.5 |
|
|
| write | 1970-01-01T00:00:04 | 0.6666666666666666 |
|
|
+-------+---------------------+---------------------------------------------------------------------------------+
|
|
|
|
drop table cache_hit;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table cache_miss;
|
|
|
|
Affected Rows: 0
|
|
|
|
create table cache_hit_with_null_label (
|
|
ts timestamp time index,
|
|
job string,
|
|
null_label string null,
|
|
greptime_value double,
|
|
primary key (job, null_label)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
create table cache_miss_with_null_label (
|
|
ts timestamp time index,
|
|
job string,
|
|
null_label string null,
|
|
greptime_value double,
|
|
primary key (job, null_label)
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
insert into cache_hit_with_null_label values
|
|
(3000, "read", null, 1.0),
|
|
(3000, "write", null, 2.0),
|
|
(4000, "read", null, 3.0),
|
|
(4000, "write", null, 4.0);
|
|
|
|
Affected Rows: 4
|
|
|
|
insert into cache_miss_with_null_label values
|
|
(3000, "read", null, 1.0),
|
|
(3000, "write", null, 2.0),
|
|
(4000, "read", null, 1.0),
|
|
(4000, "write", null, 2.0);
|
|
|
|
Affected Rows: 4
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3, 4, '1s') cache_hit_with_null_label / (cache_miss_with_null_label + cache_hit_with_null_label);
|
|
|
|
+-------+------------+---------------------+---------------------------------------------------------------------------------------------------------------------------------+
|
|
| job | null_label | ts | cache_hit_with_null_label.greptime_value / cache_miss_with_null_label.greptime_value + cache_hit_with_null_label.greptime_value |
|
|
+-------+------------+---------------------+---------------------------------------------------------------------------------------------------------------------------------+
|
|
| read | | 1970-01-01T00:00:03 | 0.5 |
|
|
| read | | 1970-01-01T00:00:04 | 0.75 |
|
|
| write | | 1970-01-01T00:00:03 | 0.5 |
|
|
| write | | 1970-01-01T00:00:04 | 0.6666666666666666 |
|
|
+-------+------------+---------------------+---------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3, 4, '1s') cache_hit_with_null_label / ignoring(null_label) (cache_miss_with_null_label + ignoring(null_label) cache_hit_with_null_label);
|
|
|
|
+-------+---------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| job | ts | lhs.greptime_value / rhs.cache_miss_with_null_label.greptime_value + cache_hit_with_null_label.greptime_value |
|
|
+-------+---------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| read | 1970-01-01T00:00:03 | 0.5 |
|
|
| read | 1970-01-01T00:00:04 | 0.75 |
|
|
| write | 1970-01-01T00:00:03 | 0.5 |
|
|
| write | 1970-01-01T00:00:04 | 0.6666666666666666 |
|
|
+-------+---------------------+---------------------------------------------------------------------------------------------------------------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval (3, 4, '1s') cache_hit_with_null_label / on(job) (cache_miss_with_null_label + on(job) cache_hit_with_null_label);
|
|
|
|
+-------+---------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| job | ts | lhs.greptime_value / rhs.cache_miss_with_null_label.greptime_value + cache_hit_with_null_label.greptime_value |
|
|
+-------+---------------------+---------------------------------------------------------------------------------------------------------------+
|
|
| read | 1970-01-01T00:00:03 | 0.5 |
|
|
| read | 1970-01-01T00:00:04 | 0.75 |
|
|
| write | 1970-01-01T00:00:03 | 0.5 |
|
|
| write | 1970-01-01T00:00:04 | 0.6666666666666666 |
|
|
+-------+---------------------+---------------------------------------------------------------------------------------------------------------+
|
|
|
|
drop table cache_hit_with_null_label;
|
|
|
|
Affected Rows: 0
|
|
|
|
drop table cache_miss_with_null_label;
|
|
|
|
Affected Rows: 0
|
|
|
|
-- Physical table for test
|
|
CREATE TABLE test_physical (greptime_timestamp timestamp time index, greptime_value double) engine=metric with ("physical_metric_table" = "");
|
|
|
|
Affected Rows: 0
|
|
|
|
CREATE TABLE IF NOT EXISTS node_network_transmit_bytes_total (
|
|
cloud STRING NULL,
|
|
dest_port STRING NULL,
|
|
dest STRING NULL,
|
|
greptime_timestamp TIMESTAMP(3) NOT NULL,
|
|
greptime_value DOUBLE NULL,
|
|
host STRING NULL,
|
|
job STRING NULL,
|
|
node STRING NULL,
|
|
"region" STRING NULL,
|
|
src_port STRING NULL,
|
|
src STRING NULL,
|
|
src_namespace STRING NULL,
|
|
src_node STRING NULL,
|
|
src_pod STRING NULL,
|
|
az STRING NULL,
|
|
TIME INDEX (greptime_timestamp),
|
|
PRIMARY KEY (cloud, dest_port, dest, host, job, node, region, src_port, src, src_namespace, src_node, src_pod, az)
|
|
)
|
|
ENGINE=metric
|
|
WITH(
|
|
on_physical_table = 'test_physical'
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO node_network_transmit_bytes_total (
|
|
cloud, dest_port, dest, greptime_timestamp, greptime_value, host, job, node, region, src_port, src, src_namespace, src_node, src_pod, az
|
|
) VALUES
|
|
('cloud-1', '443', '10.0.0.2', 1000000, 1000, 'host-1', 'greptimedb', 'node-a', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-1', 'pod-1', 'us-west-6'),
|
|
('cloud-1', '443', '10.0.0.2', 1200000, 2000, 'host-1', 'greptimedb', 'node-a', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-1', 'pod-1', 'us-west-6'),
|
|
('cloud-1', '443', '10.0.0.3', 1000000, 1500, 'host-2', 'greptimedb', 'node-b', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-2', 'pod-2', 'us-west-6'),
|
|
('cloud-1', '443', '10.0.0.3', 1200000, 2500, 'host-2', 'greptimedb', 'node-b', 'us-west', '8080', '10.0.0.1', 'namespace-1', 'node-2', 'pod-2', 'us-west-6'),
|
|
('cloud-2', '80', '10.0.0.5', 1000000, 800, 'host-3', 'greptimedb', 'node-c', 'us-west', '9000', '10.0.0.4', 'namespace-2', 'node-3', 'pod-3', 'us-west-6'),
|
|
('cloud-2', '80', '10.0.0.5', 1200000, 1800, 'host-3', 'greptimedb', 'node-c', 'us-west', '9000', '10.0.0.4', 'namespace-2', 'node-3', 'pod-3', 'us-west-6');
|
|
|
|
Affected Rows: 6
|
|
|
|
-- Or with unknown label and metric.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval(1000, 2000, '300s') unknown_metric or node_network_transmit_bytes_total;
|
|
|
|
+---------------------+-----------+---------+----------+-----------+--------+------------+--------+---------+----------+---------------+----------+---------+----------+--------+
|
|
| time | az | cloud | dest | dest_port | host | job | node | region | src | src_namespace | src_node | src_pod | src_port | value |
|
|
+---------------------+-----------+---------+----------+-----------+--------+------------+--------+---------+----------+---------------+----------+---------+----------+--------+
|
|
| 1970-01-01T00:16:40 | us-west-6 | cloud-1 | 10.0.0.2 | 443 | host-1 | greptimedb | node-a | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | 8080 | 1000.0 |
|
|
| 1970-01-01T00:16:40 | us-west-6 | cloud-1 | 10.0.0.3 | 443 | host-2 | greptimedb | node-b | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | 8080 | 1500.0 |
|
|
| 1970-01-01T00:16:40 | us-west-6 | cloud-2 | 10.0.0.5 | 80 | host-3 | greptimedb | node-c | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | 9000 | 800.0 |
|
|
| 1970-01-01T00:21:40 | us-west-6 | cloud-1 | 10.0.0.2 | 443 | host-1 | greptimedb | node-a | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | 8080 | 2000.0 |
|
|
| 1970-01-01T00:21:40 | us-west-6 | cloud-1 | 10.0.0.3 | 443 | host-2 | greptimedb | node-b | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | 8080 | 2500.0 |
|
|
| 1970-01-01T00:21:40 | us-west-6 | cloud-2 | 10.0.0.5 | 80 | host-3 | greptimedb | node-c | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | 9000 | 1800.0 |
|
|
+---------------------+-----------+---------+----------+-----------+--------+------------+--------+---------+----------+---------------+----------+---------+----------+--------+
|
|
|
|
-- Or with unknown label and metric.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval(1000, 2000, '300s') sum by (cloud, tag0, tag1) (node_network_transmit_bytes_total) or unknown_metric;
|
|
|
|
+---------------------+---------+-------------------------------------------------------+
|
|
| greptime_timestamp | cloud | sum(node_network_transmit_bytes_total.greptime_value) |
|
|
+---------------------+---------+-------------------------------------------------------+
|
|
| 1970-01-01T00:16:40 | cloud-1 | 2500.0 |
|
|
| 1970-01-01T00:16:40 | cloud-2 | 800.0 |
|
|
| 1970-01-01T00:21:40 | cloud-1 | 4500.0 |
|
|
| 1970-01-01T00:21:40 | cloud-2 | 1800.0 |
|
|
+---------------------+---------+-------------------------------------------------------+
|
|
|
|
-- Or with unknown label and metric.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval(1000, 2000, '300s') unknown_metric or unknown_metric1 or sum by (cloud, tag0, tag1) (node_network_transmit_bytes_total);
|
|
|
|
+---------------------+---------+--------+
|
|
| time | cloud | value |
|
|
+---------------------+---------+--------+
|
|
| 1970-01-01T00:16:40 | cloud-1 | 2500.0 |
|
|
| 1970-01-01T00:16:40 | cloud-2 | 800.0 |
|
|
| 1970-01-01T00:21:40 | cloud-1 | 4500.0 |
|
|
| 1970-01-01T00:21:40 | cloud-2 | 1800.0 |
|
|
+---------------------+---------+--------+
|
|
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval(1000, 2000, '300s') sum by (cloud, tag0, tag1) (node_network_transmit_bytes_total) or sum by (cloud, tag0, tag1) (unknown_metric);
|
|
|
|
+---------------------+---------+-------------------------------------------------------+
|
|
| greptime_timestamp | cloud | sum(node_network_transmit_bytes_total.greptime_value) |
|
|
+---------------------+---------+-------------------------------------------------------+
|
|
| 1970-01-01T00:16:40 | cloud-1 | 2500.0 |
|
|
| 1970-01-01T00:16:40 | cloud-2 | 800.0 |
|
|
| 1970-01-01T00:21:40 | cloud-1 | 4500.0 |
|
|
| 1970-01-01T00:21:40 | cloud-2 | 1800.0 |
|
|
+---------------------+---------+-------------------------------------------------------+
|
|
|
|
-- Or with unknown label dst_namespace.
|
|
-- SQLNESS SORT_RESULT 3 1
|
|
tql eval(1000, 2000, '300s') sum by (src, src_pod, src_namespace, src_node, dest, dst_pod, dst_namespace, dst_node, cloud, region, az) (increase(node_network_transmit_bytes_total{src_node!="", job=~"greptimedb", region=~"us-west", az=~"us-west-6"}[900s])>0) or sum by (src, src_pod, src_namespace, src_node, dest, dst_pod, dst_namespace, dst_node, cloud, region, az) (increase(node_network_transmit_bytes_total{dst_node!="", job=~"greptimedb", region=~"us-west", az=~"us-west-6"}[900s])>0);
|
|
|
|
+---------------------+-----------+---------+----------+---------+----------+---------------+----------+---------+----------------------------------------------------------------------------------------------+
|
|
| greptime_timestamp | az | cloud | dest | region | src | src_namespace | src_node | src_pod | sum(prom_increase(greptime_timestamp_range,greptime_value,greptime_timestamp,Int64(900000))) |
|
|
+---------------------+-----------+---------+----------+---------+----------+---------------+----------+---------+----------------------------------------------------------------------------------------------+
|
|
| 1970-01-01T00:21:40 | us-west-6 | cloud-1 | 10.0.0.2 | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | 2000.0 |
|
|
| 1970-01-01T00:21:40 | us-west-6 | cloud-1 | 10.0.0.3 | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | 2000.0 |
|
|
| 1970-01-01T00:21:40 | us-west-6 | cloud-2 | 10.0.0.5 | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | 2000.0 |
|
|
| 1970-01-01T00:26:40 | us-west-6 | cloud-1 | 10.0.0.2 | us-west | 10.0.0.1 | namespace-1 | node-1 | pod-1 | 2000.0 |
|
|
| 1970-01-01T00:26:40 | us-west-6 | cloud-1 | 10.0.0.3 | us-west | 10.0.0.1 | namespace-1 | node-2 | pod-2 | 2000.0 |
|
|
| 1970-01-01T00:26:40 | us-west-6 | cloud-2 | 10.0.0.5 | us-west | 10.0.0.4 | namespace-2 | node-3 | pod-3 | 2000.0 |
|
|
+---------------------+-----------+---------+----------+---------+----------+---------------+----------+---------+----------------------------------------------------------------------------------------------+
|
|
|
|
DROP TABLE node_network_transmit_bytes_total;
|
|
|
|
Affected Rows: 0
|
|
|
|
DROP TABLE test_physical;
|
|
|
|
Affected Rows: 0
|
|
|