Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: document arrow endpoint api #1189

Merged
merged 5 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/user-guide/protocols/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,44 @@ The response contains the following fields:
- `rows`: The rows of the query result, where each row is an array containing the corresponding values of the columns in the schema.
- `execution_time_ms`: The execution time of the statement in milliseconds.

### Alternative formats

In addition to the default JSON format, the HTTP API also allows you to
customize output format by providing the `format` query parameter with following
values:

- `influxdb_v1`: [influxdb query
API](https://docs.influxdata.com/influxdb/v1/tools/api/#query-http-endpoint)
compatible format. Additional parameters:
- `epoch`: `[ns,u,µ,ms,s,m,h]`, returns epoch timestamps with the specified
precision
- `csv`: output in comma separated values
- `arrow`: [Arrow IPC
format](https://arrow.apache.org/docs/python/feather.html). Additional
parameters:
- `compression`: `zstd` or `lz4`, default: no compression
- `table`: ASCII table format for console output

sunng87 marked this conversation as resolved.
Show resolved Hide resolved
Call the SQL API with `table` format as an example:

```shell
curl -X POST \
-H 'Authorization: Basic {{authorization if exists}}' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "sql=SELECT * FROM monitor" \
http://localhost:4000/v1/sql?db=public&format=table
```

Output

```
┌─host────────┬─ts────────────┬─cpu─┬─memory─┐
│ "127.0.0.1" │ 1667446797450 │ 0.1 │ 0.4 │
│ "127.0.0.1" │ 1667446798450 │ 0.5 │ 0.2 │
│ "127.0.0.2" │ 1667446798450 │ 0.2 │ 0.3 │
└─────────────┴───────────────┴─────┴────────┘
```

## POST PromQL Queries

GreptimeDB also exposes an custom HTTP API for querying with PromQL, and returning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,43 @@ curl -X POST \
- `rows`:查询结果的行数据,每行是一个数组,包含 schema 中对应列的值。
- `execution_time_ms`:该语句的执行时间,以毫秒为单位。

### 其他输出格式


除了默认的 JSON 格式外,通过指定 `format` 参数,HTTP API 还支持自定义以下输出格
式:

- `influxdb_v1`: [influxdb 查询接
口](https://docs.influxdata.com/influxdb/v1/tools/api/#query-http-endpoint)兼
容格式,支持额外参数:
- `epoch`: `[ns,u,µ,ms,s,m,h]`, 控制输出时间戳精度
- `csv`: CSV 格式
- `arrow`: [Arrow IPC 格式](https://arrow.apache.org/docs/python/feather.html).
支持额外的参数:
- `compression`: `zstd` or `lz4`, 默认不设置压缩
- `table`: 用于终端数据的 ASCII 表格格式

以输出 `table` 格式为例:

```shell
curl -X POST \
-H 'Authorization: Basic {{authorization if exists}}' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d "sql=SELECT * FROM monitor" \
http://localhost:4000/v1/sql?db=public&format=table
```

Output
nicecui marked this conversation as resolved.
Show resolved Hide resolved

```
┌─host────────┬─ts────────────┬─cpu─┬─memory─┐
│ "127.0.0.1" │ 1667446797450 │ 0.1 │ 0.4 │
│ "127.0.0.1" │ 1667446798450 │ 0.5 │ 0.2 │
│ "127.0.0.2" │ 1667446798450 │ 0.2 │ 0.3 │
└─────────────┴───────────────┴─────┴────────┘
```


## POST PromQL 查询

GreptimeDB 同样暴露了一个自己的 HTTP API 用于 PromQL 查询,即在当前的 API 路径 `/v1` 的后方拼接 `/promql`,如下示例:
Expand Down