Try Out GreptimeDB

Begin to explore GreptimeDB’s powerful core features.

Installation

You can try out GreptimeDB with our test builds released on the Download page.

We use the simplest configuration for you to get started. For a comprehensive list of configurations available in GreptimeDB, see the configuration documentation.

Binary

For Linux and macOS users, you can download the latest build of the greptime binary by using the following commands:

shell

  1. curl -fsSL \
  2. https://raw.githubusercontent.com/greptimeteam/greptimedb/develop/scripts/install.sh | sh

Once the download is completed, the binary file greptime will be stored in your current directory.

You can run GreptimeDB in the standalone mode:

shell

  1. ./greptime standalone start

Docker

Make sure the Docker is already installed. If not, you can follow the official documents to install Docker.

shell

  1. docker run -p 4000-4003:4000-4003 \
  2. -p 4242:4242 -v "$(pwd)/greptimedb:/tmp/greptimedb" \
  3. --name greptime --rm \
  4. greptime/greptimedb standalone start \
  5. --http-addr 0.0.0.0:4000 \
  6. --rpc-addr 0.0.0.0:4001 \
  7. --mysql-addr 0.0.0.0:4002 \
  8. --postgres-addr 0.0.0.0:4003 \
  9. --opentsdb-addr 0.0.0.0:4242

The data will be stored in the greptimedb/ directory in your current directory.

If you want to use another version of GreptimeDB’s image, you can download it from our GreptimeDB Dockerhub. In particular, we support GreptimeDB based on CentOS, and you can try image greptime/greptimedb-centos.

NOTE

If you are using a Docker version lower than v23.0, you may experience problems with insufficient permissions when trying to run the command above, due to a bug in the older version of Docker Engine.

You can:

  1. Set --security-opt seccomp=unconfined, for example:

    shell

    1. docker run --security-opt seccomp=unconfined -p 4000-4003:4000-4003 \
    2. -p 4242:4242 -v "$(pwd)/greptimedb:/tmp/greptimedb" \
    3. --name greptime --rm \
    4. greptime/greptimedb standalone start \
    5. --http-addr 0.0.0.0:4000 \
    6. --rpc-addr 0.0.0.0:4001 \
    7. --mysql-addr 0.0.0.0:4002 \
    8. --postgres-addr 0.0.0.0:4003 \
    9. --opentsdb-addr 0.0.0.0:4242
  2. Upgrade the Docker version to v23.0.0 or higher;

Connect

GreptimeDB supports multiple protocols. We use MySQL client here for simplicity.

sql

  1. mysql -h 127.0.0.1 -P 4002

Also, you can use PostgreSQL to connect the database:

  1. psql -h 127.0.0.1 -p 4003 -d public

Create table

Note: GreptimeDB offers a schemaless approach to writing data that eliminates the need to manually create tables using additional protocols. See Automatic Schema Generation.

Now we create a table via MySQL. Let’s start by creating the system_metrics table which contains system resource metrics, including CPU/memory/disk usage. The data is scraped every 5 seconds.

sql

  1. CREATE TABLE IF NOT EXISTS system_metrics (
  2. host STRING,
  3. idc STRING,
  4. cpu_util DOUBLE,
  5. memory_util DOUBLE,
  6. disk_util DOUBLE,
  7. ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  8. PRIMARY KEY(host, idc),
  9. TIME INDEX(ts)
  10. );

Field descriptions:

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
  • The table can be created automatically if you are using other protocols. See Create Table.
  • For more information about creating table SQL, please refer to CREATE.
  • For data types, please check data types.

Insert data

Using the INSERT statement is an easy way to add data to your table. The following statement allows us to insert several rows into the system_metrics table.

sql

  1. INSERT INTO system_metrics
  2. VALUES
  3. ("host1", "idc_a", 11.8, 10.3, 10.3, 1667446797450),
  4. ("host1", "idc_a", 80.1, 70.3, 90.0, 1667446797550),
  5. ("host1", "idc_b", 50.0, 66.7, 40.6, 1667446797650),
  6. ("host1", "idc_b", 51.0, 66.5, 39.6, 1667446797750),
  7. ("host1", "idc_b", 52.0, 66.9, 70.6, 1667446797850),
  8. ("host1", "idc_b", 53.0, 63.0, 50.6, 1667446797950),
  9. ("host1", "idc_b", 78.0, 66.7, 20.6, 1667446798050),
  10. ("host1", "idc_b", 68.0, 63.9, 50.6, 1667446798150),
  11. ("host1", "idc_b", 90.0, 39.9, 60.6, 1667446798250);

For more information about the INSERT statement, please refer to INSERT.

Query data

To select all the data from the system_metrics table, use the SELECT statement:

sql

  1. SELECT * FROM system_metrics;

The query result looks like the following:

  1. +-------+-------+----------+-------------+-----------+---------------------+
  2. | host | idc | cpu_util | memory_util | disk_util | ts |
  3. +-------+-------+----------+-------------+-----------+---------------------+
  4. | host1 | idc_a | 11.8 | 10.3 | 10.3 | 2022-11-03 03:39:57 |
  5. | host1 | idc_a | 80.1 | 70.3 | 90 | 2022-11-03 03:39:57 |
  6. | host1 | idc_b | 50 | 66.7 | 40.6 | 2022-11-03 03:39:57 |
  7. | host1 | idc_b | 51 | 66.5 | 39.6 | 2022-11-03 03:39:57 |
  8. | host1 | idc_b | 52 | 66.9 | 70.6 | 2022-11-03 03:39:57 |
  9. | host1 | idc_b | 53 | 63 | 50.6 | 2022-11-03 03:39:57 |
  10. | host1 | idc_b | 78 | 66.7 | 20.6 | 2022-11-03 03:39:58 |
  11. | host1 | idc_b | 68 | 63.9 | 50.6 | 2022-11-03 03:39:58 |
  12. | host1 | idc_b | 90 | 39.9 | 60.6 | 2022-11-03 03:39:58 |
  13. +-------+-------+----------+-------------+-----------+---------------------+
  14. 9 rows in set (0.00 sec)

You can use the count() function to get the number of all rows in the table:

sql

  1. SELECT count(*) FROM system_metrics;
  1. +-----------------+
  2. | COUNT(UInt8(1)) |
  3. +-----------------+
  4. | 9 |
  5. +-----------------+

The avg() function returns the average value of a certain field:

sql

  1. SELECT avg(cpu_util) FROM system_metrics;
  1. +------------------------------+
  2. | AVG(system_metrics.cpu_util) |
  3. +------------------------------+
  4. | 59.32222222222222 |
  5. +------------------------------+

You can use the GROUP BY clause to group rows that have the same values into summary rows. The average memory usage grouped by idc:

sql

  1. SELECT idc, avg(memory_util) FROM system_metrics GROUP BY idc;
  1. +-------+---------------------------------+
  2. | idc | AVG(system_metrics.memory_util) |
  3. +-------+---------------------------------+
  4. | idc_a | 40.3 |
  5. | idc_b | 61.942857142857136 |
  6. +-------+---------------------------------+
  7. 2 rows in set (0.03 sec)

For more information about the SELECT statement, please refer to SELECT.

Visualize data

Visualization plays a crucial role in effectively utilizing time series data. To help users leverage the various features of GreptimeDB, Greptime offers a simple dashboard.

The Dashboard is embedded into GreptimeDB’s binary since GreptimeDB v0.2.0. After starting GreptimeDB, the dashboard can be visited via HTTP endpoint http://localhost:4000/dashboard. The current version of the dashboard supports MySQL and Python queries, with support for PromQL coming soon.

Write SQL into the command text, then click Run All. We’ll got all data in system_metrics table.

  1. SELECT * FROM system_metrics;

dashboard-select

We offer various chart types to choose from based on different scenarios. The content of the charts will be richer when you have enough data.

linescatter

We are committed to the ongoing development and iteration of this open source project, and we plan to expand the application of time series data in monitoring, analysis, and other relevant fields in the future.

Next steps

Congratulations you have learned the basic features of GreptimeDB. You are ready for the User Guide chapter.