Create a Time-Series Table
To get started, create a time-series table to save the data collected from hosts.
Let's start by creating the system_metrics
table:
sql
CREATE TABLE IF NOT EXISTS 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)
);
You can execute this statement via MySQL or PostgreSQL command line.
For more information about how to create tables, please refer to CREATE for more information.
Table details
system_metrics
: contains system resource metrics, including CPU/memory/disk usage scraped every 5 seconds.
Field | Type | Description |
---|---|---|
host | string | The hostname |
idc | string | The idc name where the host belongs to |
cpu_util | double | The percent use of CPU |
memory_util | double | The percent use of memory |
disk_util | double | The percent use of disks |
ts | timestamp | Timestamp column incrementing |
Greptimedb supports several SQL data types.