Skip to content
On this page

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.

FieldTypeDescription
hoststringThe hostname
idcstringThe idc name where the host belongs to
cpu_utildoubleThe percent use of CPU
memory_utildoubleThe percent use of memory
disk_utildoubleThe percent use of disks
tstimestampTimestamp column incrementing

Greptimedb supports several SQL data types.