OpenTSDB

GreptimeDB supports ingesting OpenTSDB via Telnet or HTTP API.

Insert

Telnet

GreptimeDB fully supports OpenTSDB’s “put” command format:

put <metric> <timestamp> <value> <tagk1=tagv1[tagk2=tagv2...tagkN=tagvN]>

You can use put to insert metrics:

shell

  1. ~ % telnet 127.0.0.1 4242
  2. Trying 127.0.0.1...
  3. Connected to localhost.
  4. Escape character is '^]'.
  5. put sys.cpu.system 1667892080 3 host=web01 dc=hz
  6. put sys.cpu.system 1667892080 2 host=web02 dc=hz
  7. put sys.cpu.system 1667892080 2 host=web03 dc=hz
  8. put sys.cpu.system 1667892081 1 host=web01
  9. put sys.cpu.system 1667892081 4 host=web04 dc=sh
  10. put sys.cpu.system 1667892082 10 host=web10 dc=sh
  11. quit
  12. Connection closed by foreign host.
  13. ~ %

GreptimeDB treats each metric as an individual table, and makes tags its columns. greptime_timestamp and greptime_value are two reserved columns, corresponding to timestamp and value in put command.

GreptimeDB will automatically creates the metrics table after you put the metrics so you don’t need to create the metrics table manually.

Note that only “put” command is supported, other commands such as “histogram” or “stats” are not supported.

HTTP API

GreptimeDB also supports inserting OpenTSDB metrics via HTTP endpoints. We use the request and response format described in OpenTSDB’s /api/put.

The HTTP endpoint in GreptimeDB for handling metrics is /opentsdb/api/put

Note: remember to prefix the path with GreptimeDB’s http API version, v1.

Starting GreptimeDB, the HTTP server is listening on port 4000 by default.

Use curl to insert one metric point:

shell

  1. curl -X POST http://127.0.0.1:4000/v1/opentsdb/api/put -d '
  2. {
  3. "metric": "sys.cpu.nice",
  4. "timestamp": 1667898896,
  5. "value": 18,
  6. "tags": {
  7. "host": "web01",
  8. "dc": "hz"
  9. }
  10. }
  11. '

Or insert multiple metric points:

shell

  1. curl -X POST http://127.0.0.1:4000/v1/opentsdb/api/put -d '
  2. [
  3. {
  4. "metric": "sys.cpu.nice",
  5. "timestamp": 1667898896,
  6. "value": 1,
  7. "tags": {
  8. "host": "web02",
  9. "dc": "hz"
  10. }
  11. },
  12. {
  13. "metric": "sys.cpu.nice",
  14. "timestamp": 1667898897,
  15. "value": 9,
  16. "tags": {
  17. "host": "web03",
  18. "dc": "sh"
  19. }
  20. }
  21. ]
  22. '