-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
- Loading branch information
Showing
5 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
CREATE TABLE system_metrics ( | ||
host STRING, | ||
idc STRING, | ||
cpu_util DOUBLE, | ||
memory_util DOUBLE, | ||
disk_util DOUBLE, | ||
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY(host, idc), | ||
TIME INDEX(ts) | ||
); | ||
|
||
Failed to execute, error: Datanode { code: 1004, msg: "Failed to create table: system_metrics, source: Table already exists: greptime.public.system_metrics" } | ||
|
||
INSERT INTO system_metrics | ||
VALUES | ||
("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450), | ||
("host2", "idc_a", 80.1, 70.3, 90.0, 1667446797450), | ||
("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797450); | ||
|
||
MutateResult { success: 3, failure: 0 } | ||
|
||
SELECT * FROM system_metrics; | ||
|
||
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+ | ||
| host, #Field, #String | idc, #Field, #String | cpu_util, #Field, #Float64 | memory_util, #Field, #Float64 | disk_util, #Field, #Float64 | ts, #Timestamp, #Timestamp | | ||
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+ | ||
| host1 | idc_a | 11.8 | 10.3 | 10.3 | 1667446797450 | | ||
| host1 | idc_b | 50 | 66.7 | 40.6 | 1667446797450 | | ||
| host2 | idc_a | 80.1 | 70.3 | 90 | 1667446797450 | | ||
+-----------------------+----------------------+----------------------------+-------------------------------+-----------------------------+----------------------------+ | ||
|
||
SELECT count(*) FROM system_metrics; | ||
|
||
+----------------------------------+ | ||
| COUNT(UInt8(1)), #Field, #Uint64 | | ||
+----------------------------------+ | ||
| 3 | | ||
+----------------------------------+ | ||
|
||
SELECT avg(cpu_util) FROM system_metrics; | ||
|
||
+------------------------------------------------+ | ||
| AVG(system_metrics.cpu_util), #Field, #Float64 | | ||
+------------------------------------------------+ | ||
| 47.29999999999999 | | ||
+------------------------------------------------+ | ||
|
||
SELECT idc, avg(memory_util) FROM system_metrics GROUP BY idc ORDER BY idc; | ||
|
||
+----------------------+---------------------------------------------------+ | ||
| idc, #Field, #String | AVG(system_metrics.memory_util), #Field, #Float64 | | ||
+----------------------+---------------------------------------------------+ | ||
| idc_a | 40.3 | | ||
| idc_b | 66.7 | | ||
+----------------------+---------------------------------------------------+ | ||
|
||
DROP TABLE system_metrics; | ||
|
||
Failed to execute, error: Datanode { code: 1001, msg: "Failed to execute sql, source: Cannot parse SQL, source: SQL statement is not supported: DROP TABLE system_metrics;, keyword: DROP" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
CREATE TABLE system_metrics ( | ||
host STRING, | ||
idc STRING, | ||
cpu_util DOUBLE, | ||
memory_util DOUBLE, | ||
disk_util DOUBLE, | ||
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP, | ||
PRIMARY KEY(host, idc), | ||
TIME INDEX(ts) | ||
); | ||
|
||
INSERT INTO system_metrics | ||
VALUES | ||
("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450), | ||
("host2", "idc_a", 80.1, 70.3, 90.0, 1667446797450), | ||
("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797450); | ||
|
||
SELECT * FROM system_metrics; | ||
|
||
SELECT count(*) FROM system_metrics; | ||
|
||
SELECT avg(cpu_util) FROM system_metrics; | ||
|
||
SELECT idc, avg(memory_util) FROM system_metrics GROUP BY idc ORDER BY idc; | ||
|
||
DROP TABLE system_metrics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters