Skip to content

Commit 9f4fb30

Browse files
Copilotsunng87killme2008
authored
docs: document new dedicated HTTP API server port (http.enable_api_server) (#2670)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Ning Sun <sunng@protonmail.com> Co-authored-by: dennis zhuang <killme2008@gmail.com>
1 parent bbb392b commit 9f4fb30

4 files changed

Lines changed: 76 additions & 0 deletions

File tree

docs/reference/http-endpoints.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,37 @@ description: Provides a full list of HTTP paths and their usage in GreptimeDB, i
55

66
# HTTP API Endpoint List
77

8+
GreptimeDB provides two HTTP servers:
9+
10+
| Server | Default address | Purpose |
11+
|--------|----------------|---------|
12+
| **Main HTTP server** | `127.0.0.1:4000` | Internal / operational use. Serves all paths, including admin endpoints such as `/health`, `/metrics`, `/config`, and `/debug/*`, as well as all `/v1` and `/dashboard` paths. Keep this port private and accessible only by trusted operators. |
13+
| **Public HTTP API server** | `127.0.0.1:4006` | User-facing access. Serves only `/v1` APIs and `/dashboard`. Safe to expose to database end-users. Disabled by default; enable it with `http.enable_api_server = true` in your configuration file. |
14+
15+
We recommend keeping the main HTTP server port for internal/operational use only. Alternatively, it can be safely exposed through an HTTP proxy, provided direct access is restricted and the proxy allows only the required protocols. But If you want to expose GreptimeDB as a service to end-users, enable the dedicated public API server and expose only its port.
16+
17+
```toml
18+
[http]
19+
# Main HTTP server — keep this internal
20+
addr = "127.0.0.1:4000"
21+
22+
# Enable the public API server and bind it to an externally accessible address
23+
enable_api_server = true
24+
api_server_addr = "0.0.0.0:4006"
25+
```
26+
27+
See the [configuration documentation](/user-guide/deployments-administration/configuration.md#protocol-options) for all `[http]` options.
28+
829
Here is the full list for the various HTTP paths and their usage in GreptimeDB:
930

1031
## Admin APIs
1132

1233
Endpoints that is not versioned (under `/v1`). For admin usage like health check, status, metrics, etc.
1334

35+
:::note
36+
Admin API endpoints are available **only** on the main HTTP server (default port `4000`). They are not exposed by the dedicated public API server even when `http.enable_api_server` is enabled.
37+
:::
38+
1439
### Health Check
1540

1641
- **Path**: `/health`

docs/user-guide/deployments-administration/configuration.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ concurrent_query_limiter_timeout = "100ms"
189189

190190
Protocol options are valid in `frontend` and `standalone` subcommands,
191191
specifying protocol server addresses and other protocol-related options.
192+
In particular, `http.enable_api_server` lets you start a dedicated public HTTP API server that serves only the `/v1` APIs and `/dashboard`, while keeping the main HTTP server for internal and operational endpoints.
193+
This separation is useful when you want to expose GreptimeDB to end users or applications without also exposing admin paths such as health, metrics, config, or debug endpoints.
194+
To use it, set `http.enable_api_server = true` and configure `http.api_server_addr` to the address you want to expose externally, while keeping `http.addr` private for operator access.
192195

193196
:::tip NOTE
194197
The HTTP protocol configuration is available for all GreptimeDB components: `frontend`, `datanode`, `flownode`, and `metasrv`.
@@ -207,6 +210,9 @@ body_limit = "64MB"
207210
enable_cors = true
208211
# cors_allowed_origins = ["https://example.com"] # Optional: customize allowed origins
209212
experimental_enable_explain_analyze_stream = true
213+
# Enable the dedicated public HTTP API server (serves /v1 and /dashboard only)
214+
enable_api_server = false
215+
api_server_addr = "127.0.0.1:4006"
210216
[grpc]
211217
bind_addr = "127.0.0.1:4001"
212218
runtime_size = 8
@@ -281,6 +287,8 @@ The following table describes the options in detail:
281287
| | enable_cors | Boolean | Whether to enable HTTP CORS support, true by default. |
282288
| | cors_allowed_origins | Array | Customized allowed origins for HTTP CORS. |
283289
| | experimental_enable_explain_analyze_stream | Boolean | Experimental: enable `POST /v1/sql/analyze/stream` for streaming `EXPLAIN ANALYZE VERBOSE` metrics, true by default. |
290+
| | enable_api_server | Boolean | Whether to start the dedicated public HTTP API server. This server serves only the `/v1` APIs and `/dashboard`, making it safe to expose to end users. The main HTTP server (`addr`) is intended for internal use. Disabled by default; set to `true` to enable. |
291+
| | api_server_addr | String | The address to bind the dedicated public HTTP API server, `"127.0.0.1:4006"` by default. Only takes effect when `enable_api_server` is `true`. |
284292
| grpc | | | gRPC server options |
285293
| | bind_addr | String | The address to bind the gRPC server, "127.0.0.1:4001" by default |
286294
| | runtime_size | Integer | The number of server worker threads, 8 by default |
@@ -823,6 +831,9 @@ http2_keep_alive_timeout = "3s"
823831
addr = "127.0.0.1:4000"
824832
timeout = "0s"
825833
body_limit = "64MB"
834+
## Enable the dedicated public HTTP API server (serves /v1 and /dashboard only).
835+
enable_api_server = false
836+
api_server_addr = "127.0.0.1:4006"
826837

827838
## Procedure storage options.
828839
[procedure]
@@ -971,6 +982,8 @@ timeout = "3s"
971982
| `http.addr` | String | `127.0.0.1:4000` | HTTP server address. |
972983
| `http.timeout` | String | `0s` | HTTP request timeout. Set to `0s` to disable timeout. |
973984
| `http.body_limit` | String | `64MB` | HTTP max body size. |
985+
| `http.enable_api_server` | Bool | `false` | Whether to start the dedicated public HTTP API server. When enabled, a separate server is started at `api_server_addr` that serves only `/v1` APIs and `/dashboard`. The main HTTP server is kept for internal use. |
986+
| `http.api_server_addr` | String | `127.0.0.1:4006` | The address to bind the dedicated public HTTP API server. Only takes effect when `enable_api_server` is `true`. |
974987
| `backend` | String | `etcd_store` | The datastore for metasrv.<br/>- `etcd_store` (default)<br/>- `memory_store` (In memory metadata storage - only used for testing.)<br/>- `postgres_store`<br/>- `mysql_store` |
975988
| `meta_table_name` | String | `greptime_metakv` | Table name in RDS to store metadata. Effect when using a RDS kvbackend.<br/>**Only used when backend is RDS kvbackend.** |
976989
| `meta_schema_name` | String | -- | Optional PostgreSQL schema for metadata table and election table name qualification. When PostgreSQL public schema is not writable (e.g., PostgreSQL 15+ with restricted public), set this to a writable schema. GreptimeDB will use `meta_schema_name.meta_table_name`.<br/>**Only used when backend is `postgres_store`.** |

i18n/zh/docusaurus-plugin-content-docs/current/reference/http-endpoints.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,37 @@ description: 介绍 GreptimeDB 中各种 HTTP 路径及其用法的完整列表
55

66
# HTTP API 端点列表
77

8+
GreptimeDB 提供两个 HTTP Server:
9+
10+
| Server | 默认地址 | 用途 |
11+
|--------|---------|------|
12+
| **主 HTTP Server** | `127.0.0.1:4000` | 内部/运维使用。提供所有路径,包括 `/health``/metrics``/config``/debug/*` 等管理端点,以及全部 `/v1``/dashboard` 路径。该端口应保持私有,仅对可信运维人员开放。 |
13+
| **公共 HTTP API Server** | `127.0.0.1:4006` | 面向用户的访问。仅提供 `/v1` API 和 `/dashboard`,可安全地暴露给数据库终端用户。默认禁用;可在配置文件中设置 `http.enable_api_server = true` 来启用。 |
14+
15+
建议仅在内部/运维场景下使用主 HTTP Server 端口。或者也可以通过 HTTP 代理安全地暴露该端口,前提是限制直接访问,并且代理仅允许所需的协议。但是如需将 GreptimeDB 作为服务对外暴露给终端用户,我们更推荐启用专用公共 API Server,并仅对外暴露该端口。
16+
17+
```toml
18+
[http]
19+
# 主 HTTP Server — 保持内部访问
20+
addr = "127.0.0.1:4000"
21+
22+
# 启用公共 API Server 并将其绑定到可外部访问的地址
23+
enable_api_server = true
24+
api_server_addr = "0.0.0.0:4006"
25+
```
26+
27+
详见[配置文档](/user-guide/deployments-administration/configuration.md#协议选项)中的 `[http]` 选项。
28+
829
以下是 GreptimeDB 中各种 HTTP 路径及其用法的完整列表:
930

1031
## 管理 API
1132

1233
未版本化的端点(不在 `/v1` 下)。用于健康检查、状态、指标等管理用途。
1334

35+
:::note
36+
管理 API 端点****在主 HTTP Server(默认端口 `4000`)上可用。即使启用了 `http.enable_api_server`,专用公共 API Server 也不会暴露这些端点。
37+
:::
38+
1439
### 健康检查
1540

1641
- **路径**: `/health`

i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/configuration.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ concurrent_query_limiter_timeout = "100ms"
188188
### 协议选项
189189

190190
协议选项适用于 `frontend``standalone` 子命令,它指定了协议服务器地址和其他协议相关的选项。
191+
其中,`http.enable_api_server` 可用于启动一个专门对外提供服务的公共 HTTP API Server,它只暴露 `/v1` API 和 `/dashboard`,而主 HTTP Server 继续用于内部和运维端点。
192+
这种分离方式适合希望将 GreptimeDB 暴露给终端用户或应用程序、同时又不暴露 health、metrics、config、debug 等管理路径的场景。
193+
使用时,将 `http.enable_api_server = true`,并把 `http.api_server_addr` 配置为你希望对外暴露的地址,同时将 `http.addr` 保持为仅供运维访问的内部地址。
191194

192195
:::tip 提示
193196
HTTP 协议配置适用于所有 GreptimeDB 组件:`frontend``datanode``flownode``metasrv`
@@ -206,6 +209,9 @@ body_limit = "64MB"
206209
enable_cors = true
207210
# cors_allowed_origins = ["https://example.com"] # Optional: customize allowed origins
208211
experimental_enable_explain_analyze_stream = true
212+
# 启用专用公共 HTTP API Server(仅提供 /v1 和 /dashboard)
213+
enable_api_server = false
214+
api_server_addr = "127.0.0.1:4006"
209215
[grpc]
210216
bind_addr = "127.0.0.1:4001"
211217
runtime_size = 8
@@ -280,6 +286,8 @@ max_inflight_requests = 3000
280286
| | enable_cors | 布尔值 | 是否启用 HTTP CORS 支持,默认为 true。 |
281287
| | cors_allowed_origins | 数组 | 自定义 HTTP CORS 允许的来源。 |
282288
| | experimental_enable_explain_analyze_stream | 布尔值 | 实验性:启用 `POST /v1/sql/analyze/stream`,用于流式返回 `EXPLAIN ANALYZE VERBOSE` 指标,默认为 true。 |
289+
| | enable_api_server | 布尔值 | 是否启动专用公共 HTTP API Server。该 Server 仅提供 `/v1` API 和 `/dashboard`,可安全地对外暴露给终端用户。主 HTTP Server(`addr`)用于内部使用。默认禁用;设为 `true` 可启用。 |
290+
| | api_server_addr | 字符串 | 专用公共 HTTP API Server 的绑定地址,默认为 `"127.0.0.1:4006"`。仅在 `enable_api_server``true` 时生效。 |
283291
| grpc | | | gRPC 服务器选项 |
284292
| | bind_addr | 字符串 | gRPC 服务绑定地址,默认为 "127.0.0.1:4001" |
285293
| | runtime_size | 整数 | 服务器工作线程数量,默认为 8 |
@@ -827,6 +835,9 @@ http2_keep_alive_timeout = "3s"
827835
addr = "127.0.0.1:4000"
828836
timeout = "0s"
829837
body_limit = "64MB"
838+
## 启用专用公共 HTTP API Server(仅提供 /v1 和 /dashboard)。
839+
enable_api_server = false
840+
api_server_addr = "127.0.0.1:4006"
830841

831842
## Procedure 选项
832843
[procedure]
@@ -957,6 +968,8 @@ timeout = "3s"
957968
| `http.addr` | String | `127.0.0.1:4000` | HTTP 服务器地址。 |
958969
| `http.timeout` | String | `0s` | HTTP 请求超时时间。设为 `0s` 可禁用超时。 |
959970
| `http.body_limit` | String | `64MB` | HTTP 最大 body 大小。 |
971+
| `http.enable_api_server` | Bool | `false` | 是否启动专用公共 HTTP API Server。启用后,会在 `api_server_addr` 地址启动一个独立 Server,仅提供 `/v1` API 和 `/dashboard`。主 HTTP Server 保留用于内部使用。 |
972+
| `http.api_server_addr` | String | `127.0.0.1:4006` | 专用公共 HTTP API Server 的绑定地址。仅在 `enable_api_server``true` 时生效。 |
960973
| `backend` | String | `etcd_store` | 元数据存储类型。<br/>- `etcd_store` (默认)<br/>- `memory_store` (纯内存存储 - 仅用于测试)<br/>- `postgres_store`<br/>- `mysql_store` |
961974
| `meta_table_name` | String | `greptime_metakv` | 使用 RDS 存储元数据时的表名。**仅在 backend 为 RDS kvbackend 时有效。** |
962975
| `meta_schema_name` | String | -- | 可选的 PostgreSQL schema,用于元数据表和选举表名称限定。当 PostgreSQL public schema 不可写入时(例如 PostgreSQL 15+ 限制 public schema),可设置此参数为可写入的 schema。GreptimeDB 将使用 `meta_schema_name.meta_table_name`。<br/>**仅在 backend 为 postgres_store 时有效。** |

0 commit comments

Comments
 (0)