# GreptimeDB Deployment Configuration

> Detailed guide on configuring GreptimeDB, including command line options, configuration file options, environment variables, and default values for various components and features.

# Configuration

GreptimeDB supports **layered configuration** with the following precedence order (where each item overrides the one below it):

- Greptime command line options
- Configuration file options
- Environment variables
- Default values

You only need to set up the configurations you require.
GreptimeDB will assign default values for any settings not configured.

## How to set up configurations

### Greptime command line options

You can specify several configurations using command line arguments.
For example, to start GreptimeDB in standalone mode with a configured HTTP address:

```shell
greptime standalone start --http-addr 127.0.0.1:4000
```

For all the options supported by the Greptime command line,
refer to the [GreptimeDB Command Line Interface](/reference/command-lines/overview.md).

### Configuration file options

You can specify configurations in a TOML file.
For example, create a configuration file `standalone.example.toml` as shown below:

```toml
[storage]
data_home = "./greptimedb_data"
type = "File"
```

Then, specify the configuration file using the command line argument `-c [file_path]`.

```sh
greptime [standalone | frontend | datanode | flownode | metasrv] start -c config/standalone.example.toml
```

For example, to start in standalone mode:

```bash
greptime standalone start -c standalone.example.toml
```

#### Example files

Below are example configuration files for each GreptimeDB component,
including all available configurations.
In actual scenarios,
you only need to configure the required options and do not need to configure all options as in the sample file.

- [standalone](https://github.com/GreptimeTeam/greptimedb/blob/v1.3.0/config/standalone.example.toml)
- [frontend](https://github.com/GreptimeTeam/greptimedb/blob/v1.3.0/config/frontend.example.toml)
- [datanode](https://github.com/GreptimeTeam/greptimedb/blob/v1.3.0/config/datanode.example.toml)
- [flownode](https://github.com/GreptimeTeam/greptimedb/blob/v1.3.0/config/flownode.example.toml)
- [metasrv](https://github.com/GreptimeTeam/greptimedb/blob/v1.3.0/config/metasrv.example.toml)

### Helm Configurations

When deploying GreptimeDB on Kubernetes using Helm charts,
you can configure certain settings directly in the Helm `values.yaml` file.
Please refer to the [Helm configuration documentation](/user-guide/deployments-administration/deploy-on-kubernetes/common-helm-chart-configurations.md) for all Helm-supported configurations.

For configurations that are available only in the [options](#options) section of this document,
you can [inject complete TOML configuration files](/user-guide/deployments-administration/deploy-on-kubernetes/common-helm-chart-configurations.md#injecting-configuration-files) into your deployment.

### Environment variable

Every item in the configuration file can be mapped to environment variables.
For example, to set the `data_home` configuration item for the datanode using an environment variable:

```toml
# ...
[storage]
data_home = "/data/greptimedb"
# ...
```

Use the following shell command to set the environment variable in the following format:

```
export GREPTIMEDB_DATANODE__STORAGE__DATA_HOME=/data/greptimedb
```

#### Environment Variable Rules

- Each environment variable should have the component prefix, for example:
  - `GREPTIMEDB_FRONTEND`
  - `GREPTIMEDB_METASRV`
  - `GREPTIMEDB_DATANODE`
  - `GREPTIMEDB_FLOWNODE`
  - `GREPTIMEDB_STANDALONE`

- Use **double underscore `__`** separators. For example, the data structure `storage.data_home` is transformed to `STORAGE__DATA_HOME`.

The environment variable also accepts lists that are separated by commas `,`, for example:

```
GREPTIMEDB_METASRV__META_CLIENT__METASRV_ADDRS=127.0.0.1:3001,127.0.0.1:3002,127.0.0.1:3003
```

## Options

In this section, we will introduce some main configuration options.
For all options, refer to the [Configuration Reference](https://github.com/GreptimeTeam/greptimedb/blob/v1.3.0/config/config.md) on Github.

### Runtime options

GreptimeDB executes background work on several dedicated Tokio runtimes.
These options are valid in all subcommands (`standalone`, `datanode`, `frontend`, and `metasrv`).

```toml
[runtime]
# The number of threads to execute the runtime for global read operations.
# Defaults to the number of CPU cores.
global_rt_size = 8

# The number of threads to execute compaction operations.
# Defaults to max(num_cpus / 2, 1).
compact_rt_size = 4

# The maximum number of blocking threads for compaction operations.
# Compaction picker CPU work runs on the compact runtime's blocking thread pool,
# so this limit prevents bursts of compaction planning from consuming all available CPUs.
# Defaults to max(num_cpus / 2, 1). An explicit 0 is clamped to 1.
compact_rt_max_blocking_threads = 4
```

| Option                               | Type    | Default                  | Description                                                                                                                                                                            |
| ------------------------------------ | ------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `runtime.global_rt_size`             | Integer | The number of CPU cores  | The number of threads to execute the runtime for global read operations.                                                                                                                |
| `runtime.compact_rt_size`            | Integer | `max(num_cpus / 2, 1)`   | The number of threads to execute compaction operations.                                                                                                                                    |
| `runtime.compact_rt_max_blocking_threads` | Integer | `max(num_cpus / 2, 1)` | The maximum number of blocking threads for compaction operations. Compaction picker CPU work runs on this blocking thread pool. An explicit `0` is clamped to `1`.                          |

### Write memory limiter options

Memory limiter options control the total memory used by concurrent write requests across all protocols (HTTP, gRPC, and Arrow Flight).
These options are valid in `frontend` and `standalone` subcommands.

```toml
# Maximum total memory for all concurrent write request bodies and messages
# Set to 0 to disable the limit (unlimited by default)
max_in_flight_write_bytes = "1GB"

# Policy when write bytes quota is exhausted
# Options: "wait" (default, 10s timeout), "wait(<duration>)" (e.g., "wait(30s)"), "fail"
write_bytes_exhausted_policy = "wait"
```

| Option                          | Type   | Default | Description                                                                                                                                                                                                                                           |
| ------------------------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `max_in_flight_write_bytes`     | String | `0`    | Maximum total memory for all concurrent write request bodies and messages (HTTP, gRPC, Flight). Set to `0` to disable the limit (unlimited). Supports units: `B`, `KB`, `MB`, `GB`, etc. Example: `1GB` limits total concurrent writes to 1GB. |
| `write_bytes_exhausted_policy`  | String | `wait` | Policy when write bytes quota is exhausted. Options: `wait` (default, waits up to 10 seconds), `wait(<duration>)` (custom timeout, e.g., `wait(30s)`), `fail` (immediately reject the request).                                             |

### Datanode query concurrency limit

These options limit how many read queries can run at the same time on a datanode.
A query counts toward the limit until it finishes or the client closes the result stream.
If the limit is reached, a new query waits up to `concurrent_query_limiter_timeout` for an available slot before it fails.

These options are valid in the `datanode` subcommand.

```toml
# Maximum number of read queries that can run at the same time on the datanode.
# Set to 0 to disable the limit (unlimited by default).
max_concurrent_queries = 0

# Maximum time a query waits for an available slot when max_concurrent_queries is reached.
concurrent_query_limiter_timeout = "100ms"
```

| Option                             | Type    | Default   | Description                                                                                                                                              |
| ---------------------------------- | ------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `max_concurrent_queries`           | Integer | `0`       | Maximum number of read queries that can run at the same time on the datanode. Set to `0` to disable the limit.                              |
| `concurrent_query_limiter_timeout` | String  | `100ms` | Maximum time a query waits for an available slot after `max_concurrent_queries` is reached. The query fails if no slot is available in time. |

### Protocol options

Protocol options are valid in `frontend` and `standalone` subcommands,
specifying protocol server addresses and other protocol-related options.
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.
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.
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.

:::tip NOTE
The HTTP protocol configuration is available for all GreptimeDB components: `frontend`, `datanode`, `flownode`, and `metasrv`.
:::

Below is an example configuration with default values.
You can change the values or disable certain protocols in your configuration file.
For example, to disable OpenTSDB protocol support, set the `enable` parameter to `false`.
Note that HTTP and gRPC protocols cannot be disabled for the database to function correctly.

```toml
[http]
addr = "127.0.0.1:4000"
timeout = "0s"
body_limit = "64MB"
enable_cors = true
# cors_allowed_origins = ["https://example.com"]  # Optional: customize allowed origins
experimental_enable_explain_analyze_stream = true
# Enable the dedicated public HTTP API server (serves /v1 and /dashboard only)
enable_api_server = false
api_server_addr = "127.0.0.1:4006"
[grpc]
bind_addr = "127.0.0.1:4001"
runtime_size = 8

[grpc.tls]
mode = "disable"
cert_path = ""
key_path = ""
watch = false

[mysql]
enable = true
addr = "127.0.0.1:4002"
runtime_size = 2
keep_alive = "0s"
prepared_stmt_cache_size = 10000

[mysql.tls]
mode = "disable"
cert_path = ""
key_path = ""
watch = false

[postgres]
enable = true
addr = "127.0.0.1:4003"
runtime_size = 2
keep_alive = "0s"

[postgres.tls]
mode = "disable"
cert_path = ""
key_path = ""
watch = false

[opentsdb]
enable = true

[influxdb]
enable = true
# Default merge mode for tables automatically created by InfluxDB protocol.
# Available values: "last_non_null", "last_row".
default_merge_mode = "last_non_null"

[jaeger]
enable = true

[otlp]
enable = true
trace_ingest_chunk_size = 512

[prom_store]
enable = true
with_metric_engine = true
prom_validation_mode = "strict"
experimental_enable_prometheus_native_histogram = false
pending_rows_flush_interval = "0s"
max_batch_rows = 100000
max_concurrent_flushes = 256
worker_channel_capacity = 65526
max_inflight_requests = 3000
```

The following table describes the options in detail:

| Option     | Key                  | Type    | Description                                                                                                                                                                                                                                                                                                                                                                                |
| ---------- | -------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| http       |                      |         | HTTP server options                                                                                                                                                                                                                                                                                                                                                                        |
|            | addr                 | String  | Server address, "127.0.0.1:4000" by default                                                                                                                                                                                                                                                                                                                                                |
|            | timeout              | String  | HTTP request timeout. Set to `0s` to disable timeout (default: "0s"). When Prometheus Remote Write [batching mode](/user-guide/ingest-data/for-observability/prometheus.md#batching-mode) is enabled, a non-zero timeout less than or equal to `prom_store.pending_rows_flush_interval` plus 1 second is adjusted to that value.                                                                                                                                                                                                                                                                                                                                                     |
|            | body_limit           | String  | HTTP max body size, "64MB" by default                                                                                                                                                                                                                                                                                                                                                      |
|            | enable_cors          | Boolean | Whether to enable HTTP CORS support, true by default. |
|            | cors_allowed_origins | Array   | Customized allowed origins for HTTP CORS. |
|            | experimental_enable_explain_analyze_stream | Boolean | Experimental: enable `POST /v1/sql/analyze/stream` for streaming `EXPLAIN ANALYZE VERBOSE` metrics, true by default. |
|            | 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. |
|            | 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`. |
| grpc       |                      |         | gRPC server options                                                                                                                                                                                                                                                                                                                                                                        |
|            | bind_addr            | String  | The address to bind the gRPC server, "127.0.0.1:4001" by default                                                                                                                                                                                                                                                                                                                           |
|            | runtime_size         | Integer | The number of server worker threads, 8 by default                                                                                                                                                                                                                                                                                                                                          |
|            | max_connection_age   | String  | Maximum lifetime of a gRPC connection that the server keeps it. Refer to ["MAX_CONNECTION_AGE"](https://grpc.io/docs/guides/keepalive/) for details. Defaults to not set. Example: "1h" for 1 hour, "30m" for 30 minutes                                                                                                                                                                   |
|            | flight_compression   | String  | Compression mode for frontend side Arrow IPC service. Available options: `none`: disable all compression, `transport`: only enable gRPC transport compression (zstd), `arrow_ipc`: only enable Arrow IPC compression (lz4), `all`: enable all compression. Default value is `none`.                                                                                                        |
| mysql      |                      |         | MySQL server options                                                                                                                                                                                                                                                                                                                                                                       |
|            | enable               | Boolean | Whether to enable MySQL protocol, true by default                                                                                                                                                                                                                                                                                                                                          |
|            | addr                 | String  | Server address, "127.0.0.1:4002" by default                                                                                                                                                                                                                                                                                                                                                |
|            | runtime_size         | Integer | The number of server worker threads, 2 by default                                                                                                                                                                                                                                                                                                                                          |
|            | keep_alive           | String  | Server-side keep-alive time. Set to `0s` to disable. |
|            | prepared_stmt_cache_size | Integer | Maximum entries in the MySQL prepared statement cache, 10000 by default. |
| influxdb   |                      |         | InfluxDB Protocol options                                                                                                                                                                                                                                                                                                                                                                  |
|            | enable               | Boolean | Whether to enable InfluxDB protocol in HTTP API, true by default                                                                                                                                                                                                                                                                                                                           |
|            | default_merge_mode   | String  | Default merge mode for tables automatically created by InfluxDB protocol. Available values: `last_non_null`, `last_row`. Default: `last_non_null`                                                                                                                                                                                                                                           |
| opentsdb   |                      |         | OpenTSDB Protocol options                                                                                                                                                                                                                                                                                                                                                                  |
|            | enable               | Boolean | Whether to enable OpenTSDB protocol in HTTP API, true by default                                                                                                                                                                                                                                                                                                                           |
| jaeger     |                      |         | Jaeger protocol options |
|            | enable               | Boolean | Whether to enable Jaeger protocol in HTTP API, true by default. |
| otlp       |                      |         | OpenTelemetry protocol options |
|            | enable               | Boolean | Whether to enable OpenTelemetry protocol in HTTP API, true by default. |
|            | trace_ingest_chunk_size | Integer | Maximum spans per trace ingest chunk. Set to `0` to disable splitting. |
| prom_store |                              |         | Prometheus remote storage options                                                                                                                                                                                                                                                                                                                                                          |
|            | enable                       | Boolean | Whether to enable Prometheus Remote Write and read in HTTP API, true by default                                                                                                                                                                                                                                                                                                            |
|            | with_metric_engine           | Boolean | Whether to use the metric engine on Prometheus Remote Write, true by default                                                                                                                                                                                                                                                                                                               |
|            | prom_validation_mode         | String  | Whether to check if strings are valid UTF-8 strings in Prometheus remote write requests. Available options: `strict`(reject any request with invalid UTF-8 strings), `lossy`(replace invalid characters with [UTF-8 REPLACEMENT CHARACTER U+FFFD, which looks like �](https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-23/#G24272)), `unchecked`(do not validate strings). |
|            | experimental_enable_prometheus_native_histogram | Boolean | Experimental: enable Prometheus remote write v2 native histogram ingestion, false by default. |
|            | pending_rows_flush_interval  | String  | Interval between batch flushes for Prometheus Remote Write. Set to a non-zero duration (e.g. `500ms`) to enable [batching mode](/user-guide/ingest-data/for-observability/prometheus.md#batching-mode). `0s` by default (disabled)                                                                                                                                                     |
|            | max_batch_rows               | Integer | Maximum number of rows per batch before a flush is triggered, 100000 by default                                                                                                                                                                                                                                                                                                            |
|            | max_concurrent_flushes       | Integer | Maximum number of concurrent flush operations, 256 by default                                                                                                                                                                                                                                                                                                                              |
|            | worker_channel_capacity      | Integer | Capacity of the internal worker channel for receiving rows, 65526 by default                                                                                                                                                                                                                                                                                                               |
|            | max_inflight_requests        | Integer | Maximum number of in-flight write requests waiting for batch completion, 3000 by default                                                                                                                                                                                                                                                                                                   |
| postgres   |                      |         | PostgresSQL server options                                                                                                                                                                                                                                                                                                                                                                 |
|            | enable               | Boolean | Whether to enable PostgresSQL protocol, true by default                                                                                                                                                                                                                                                                                                                                    |
|            | addr                 | String  | Server address, "127.0.0.1:4003" by default                                                                                                                                                                                                                                                                                                                                                |
|            | runtime_size         | Integer | The number of server worker threads, 2 by default                                                                                                                                                                                                                                                                                                                                          |
|            | keep_alive           | String  | Server-side keep-alive time. Set to `0s` to disable. |

For MySQL, Postgres and gRPC interface, TLS can be configured to enable transport
layer security.

| Option                                    | Key         | Type    | Description                                                   |
| ----------------------------------------- | ----------- | ------- | ------------------------------------------------------------- |
| `mysql.tls`, `postgres.tls` or `grpc.tls` |             |         | TLS configuration for MySQL and Postgres                      |
|                                           | `mode`      | String  | TLS mode, options are `disable`, `prefer` and `require`       |
|                                           | `cert_path` | String  | File path for TLS certificate                                 |
|                                           | `key_path`  | String  | File path for TLS private key                                 |
|                                           | `watch`     | Boolean | Watch file system changes and reload certificate and key file. Auto reload is not supported by `grpc.tls`; keep `grpc.tls.watch` set to `false`. |

### Query options

The `query` options are valid in standalone, datanode and frontend modes, which controls the query engine's behavior.

The following table describes the options in detail:

| Option      | Key     | Type | Description                                                                         |
| ----------- | ------- | ---- | ----------------------------------------------------------------------------------- |
| parallelism | Integer | `0`  | Parallelism of the query engine. Default to 0, which means the number of CPU cores. |

A sample configuration:

```toml
[query]
parallelism = 0
```

### Storage options

The `storage` options are valid in datanode and standalone mode, which specify the database data directory and other storage-related options.

GreptimeDB supports storing data in local file system, AWS S3 and compatible services (including MinIO, digitalocean space, Tencent Cloud Object Storage(COS), Baidu Object Storage(BOS) and so on), Azure Blob Storage and Aliyun OSS.

| Option  | Key                       | Type    | Description                                                                      |
| ------- | ------------------------- | ------- | -------------------------------------------------------------------------------- |
| storage |                           |         | Storage options                                                                  |
|         | type                      | String  | Storage type, supports "File", "S3" and "Oss" etc.                               |
| File    |                           |         | Local file storage options, valid when type="File"                               |
|         | data_home                 | String  | Database storage root directory, "./greptimedb_data" by default                  |
|         | copy_root                 | String  | Root directory for standalone SQL access to local files (default `<data_home>/copy`). Relative paths in `COPY` and external tables are resolved below this directory; absolute paths are accepted only when they fall inside it. Distributed deployments always reject local-file SQL access. See [Migrate Local SQL File Access](/user-guide/deployments-administration/migrate-local-sql-file-access.md) for upgrade guidance. |
| S3      |                           |         | AWS S3 storage options, valid when type="S3"                                     |
|         | name                      | String  | The storage provider name, default is `S3`                                       |
|         | bucket                    | String  | The S3 bucket name                                                               |
|         | root                      | String  | The root path in S3 bucket                                                       |
|         | endpoint                  | String  | The API endpoint of S3                                                           |
|         | region                    | String  | The S3 region                                                                    |
|         | access_key_id             | String  | The S3 access key id                                                             |
|         | secret_access_key         | String  | The S3 secret access key                                                         |
|         | enable_virtual_host_style | Boolean | Send API requests in virtual host style instead of path style. Default is false. |
| Oss     |                           |         | Aliyun OSS storage options, valid when type="Oss"                                |
|         | name                      | String  | The storage provider name, default is `Oss`                                      |
|         | bucket                    | String  | The OSS bucket name                                                              |
|         | root                      | String  | The root path in OSS bucket                                                      |
|         | endpoint                  | String  | The API endpoint of OSS                                                          |
|         | access_key_id             | String  | The OSS AccessKey ID                                                             |
|         | access_key_secret         | String  | The OSS AccessKey Secret                                                         |
| Azblob  |                           |         | Azure Blob Storage options, valid when type="Azblob"                             |
|         | name                      | String  | The storage provider name, default is `Azblob`                                   |
|         | container                 | String  | The container name                                                               |
|         | root                      | String  | The root path in container                                                       |
|         | endpoint                  | String  | The API endpoint of Azure Blob Storage                                           |
|         | account_name              | String  | The account name of Azure Blob Storage                                           |
|         | account_key               | String  | The access key                                                                   |
|         | sas_token                 | String  | The shared access signature                                                      |
| Gcs     |                           |         | Google Cloud Storage options, valid when type="Gcs"                              |
|         | name                      | String  | The storage provider name, default is `Gcs`                                      |
|         | root                      | String  | The root path in the GCS bucket                                                      |
|         | bucket                    | String  | The GCS bucket name                                                              |
|         | scope                     | String  | The GCS service scope                                                            |
|         | credential_path           | String  | The GCS credentials path                                                         |
|         | endpoint                  | String  | The API endpoint of GCS                                                          |

A file storage sample configuration:

```toml
[storage]
data_home = "./greptimedb_data"
type = "File"
```

A S3 storage sample configuration:

```toml
[storage]
type = "S3"
bucket = "test_greptimedb"
root = "/greptimedb"
access_key_id = "<access key id>"
secret_access_key = "<secret access key>"
```

### Storage http client

`[storage.http_client]` sets the options for the http client that is used to send requests to the storage service.

Only applied for storage types "S3", "Oss", "Azblob" and "Gcs".

| Key                      | Type    | Default            | Description                                                                                                                                        |
| ------------------------ | ------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pool_max_idle_per_host` | Integer | `1024` | The maximum idle connection per host allowed in the pool.                                                                                          |
| `connect_timeout`        | String  | `30s` | The timeout for only the connect phase of a http client.                                                                                           |
| `timeout`                | String  | `30s` | The total request timeout, applied from when the request starts connecting until the response body has finished. Also considered a total deadline. |
| `pool_idle_timeout`      | String  | `90s` | The timeout for idle sockets being kept-alive.                                                                                                     |

### Storage engine provider

`[[storage.providers]]` setups the table storage engine providers. Based on these providers, you can create a table with a specified storage, see [create table](/reference/sql/create.md#create-table):

```toml
# Allows using multiple storages
[[storage.providers]]
name = "S3"
type = "S3"
bucket = "test_greptimedb"
root = "/greptimedb"
access_key_id = "<access key id>"
secret_access_key = "<secret access key>"

[[storage.providers]]
name = "Gcs"
type = "Gcs"
bucket = "test_greptimedb"
root = "/greptimedb"
credential_path = "<gcs credential path>"
```

All configured providers' names can be used as the `storage` option when creating tables.

For storage from the same provider, if you want to use different S3 buckets as storage engines for different tables, you can set different `name` values and specify the `storage` option when creating the table.

### Object storage cache

When using remote storage services like AWS S3, Alibaba Cloud OSS, or Azure Blob Storage, fetching data during queries can be time-consuming. To address this, GreptimeDB provides a write cache mechanism to speed up repeated data access.

You can configure the cache size and behavior in the mito config if you don't want to use the default values.

```toml
[[region_engine]]
[region_engine.mito]

write_cache_size = "10GiB"
# Download files from object storage to fill the cache on write cache miss
enable_refill_cache_on_read = true
```

By default, GreptimeDB automatically downloads files from object storage to fill the write cache when there's a cache miss during queries (`enable_refill_cache_on_read = true`). This improves subsequent query performance by keeping frequently accessed data in the write cache. You can disable this behavior by setting `enable_refill_cache_on_read = false` if you want to minimize network traffic or storage costs.

Read [Performance Tuning Tips](/user-guide/deployments-administration/performance-tuning/performance-tuning-tips.md) for more detailed info.

### WAL options

GreptimeDB supports three WAL storage options—Local WAL, Remote WAL, and Noop WAL. See the [WAL Overview](/user-guide/deployments-administration/wal/overview.md) for a comparison of the options. For detailed configurations, refer to the [Local WAL](/user-guide/deployments-administration/wal/local-wal.md), [Remote WAL](/user-guide/deployments-administration/wal/remote-wal/configuration.md), and [Noop WAL](/user-guide/deployments-administration/wal/noop-wal.md) documentation.

### Logging options

`frontend`, `metasrv`, `datanode` and `standalone` can all configure log and tracing related parameters in the `[logging]` section:

```toml
[logging]
dir = "./greptimedb_data/logs"
level = "info"
enable_otlp_tracing = false
enable_per_region_metrics = false
otlp_endpoint = "localhost:4317"
append_stdout = true
[logging.tracing_sample_ratio]
default_ratio = 1.0
```

- `dir`: log output directory.
- `level`: output log level, available log level are `info`, `debug`, `error`, `warn`, the default level is `info`.
- `enable_otlp_tracing`: whether to turn on tracing, not turned on by default.
- `enable_per_region_metrics`: whether to expose Prometheus per-region query load metrics, including `greptime_mito_region_query_cpu_time` and `greptime_mito_region_query_scanned_bytes`. This option is disabled by default because it creates one time series per region. Query stats reported through heartbeats and exposed in `INFORMATION_SCHEMA.REGION_STATISTICS` are not controlled by this option.
- `otlp_endpoint`: Export the target endpoint of tracing using gRPC-based OTLP protocol, the default value is `localhost:4317`.
- `append_stdout`: Whether to append logs to stdout. Defaults to `true`.
- `tracing_sample_ratio`: This field can configure the sampling rate of tracing. How to use `tracing_sample_ratio`, please refer to [How to configure tracing sampling rate](/user-guide/deployments-administration/monitoring/tracing.md#guide-how-to-configure-tracing-sampling-rate).

How to use distributed tracing, please reference [Tracing](/user-guide/deployments-administration/monitoring/tracing.md#tutorial-use-jaeger-to-trace-greptimedb)

### Event recording

Recorded events are stored in the `greptime_private.events` system table.

```toml
[event_recorder]
# TTL of the events table. Defaults to 90 days.
ttl = "90d"

# Omit this option to record all current and future event types.
# Use an empty array to disable event recording.
event_types = ["create_table", "drop_table"]
```

- `ttl`: The TTL of the events table. The default is `90d`.
- `event_types`: The event types to record. When omitted, all current and future event types are recorded. Set it to `[]` to disable event recording.

Standalone supports the following event types:

```text
create_database, alter_database, drop_database,
create_flow, drop_flow,
create_table, create_logical_tables, alter_table, alter_logical_tables,
drop_table, undrop_table, purge_dropped_table, truncate_table,
create_view, drop_view, admin_function
```

`undrop_table` and `purge_dropped_table` require GreptimeDB Enterprise.

In distributed deployments, the Frontend supports the following event type:

```text
admin_function
```

Metasrv supports the following event types:

```text
region_migration,
create_database, alter_database, drop_database,
create_flow, drop_flow,
create_table, create_logical_tables, alter_table, alter_logical_tables,
drop_table, undrop_table, purge_dropped_table, truncate_table,
create_view, drop_view,
repartition, repartition_group,
batch_gc, wal_prune
```

`undrop_table` and `purge_dropped_table` require GreptimeDB Enterprise.

### Region engine options

The parameters corresponding to different storage engines can be configured for `datanode` and `standalone` in the `[region_engine]` section. Currently, options for `mito` and `metric` region engines are available.

Frequently used options:

```toml
[[region_engine]]
[region_engine.mito]
num_workers = 8
manifest_checkpoint_distance = 10
max_background_flushes = 4
max_background_compactions = 2
max_background_purges = 4
auto_flush_interval = "1h"
global_write_buffer_size = "1GB"
global_write_buffer_reject_size = "2GB"
default_region_write_buffer_size = "0"
sst_meta_cache_size = "512MB"
vector_cache_size = "512MB"
page_cache_size = "512MB"
write_cache_size = "5GB"
write_cache_ttl = "8h"
scan_memory_limit = "unlimited"
scan_memory_on_exhausted = "fail"
min_compaction_interval = "0m"
schedule_compaction_after_edit = true
default_flat_format = true
experimental_series_scan_v2 = true
sst_write_buffer_size = "8MB"
max_concurrent_scan_files = 384

[region_engine.mito.index]
aux_path = ""
staging_size = "2GB"
staging_ttl = "7d"
metadata_cache_size = "64MiB"
content_cache_size = "128MiB"
content_cache_page_size = "64KiB"
result_cache_size = "128MiB"

[region_engine.mito.inverted_index]
create_on_flush = "auto"
create_on_compaction = "auto"
apply_on_query = "auto"
mem_threshold_on_create = "64M"
intermediate_path = ""
```

Mito selects the memtable implementation for each Region according to its table options and SST format. When `default_flat_format` is `true`, Regions without an explicit `sst_format` use flat SSTs and the bulk memtable. Configure `memtable.type` as a database or table option; `[region_engine.mito.memtable]` is not an engine setting. See [table options](/reference/sql/create.md#table-options).

Available options:

| Key                                      | Type    | Default       | Descriptions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| ---------------------------------------- | ------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `num_workers`                            | Integer | `8`           | Number of region workers.                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `manifest_checkpoint_distance`           | Integer | `10`          | Number of meta action updated to trigger a new checkpoint for the manifest.                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `compress_manifest`                      | Bool    | `false`      | Whether to compress manifest and checkpoint file by gzip.                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `max_background_flushes`                 | Integer | `Auto` | Max number of running background flush jobs (default: 1/2 of cpu cores).                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `max_background_compactions`            | Integer | `Auto` | Max number of running background compaction jobs (default: 1/4 of cpu cores).                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `max_background_purges`                | Integer | `Auto` | Max number of running background purge jobs (default: cpu cores).                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `auto_flush_interval`                    | String  | `1h`          | Interval to auto flush a region if it has not flushed yet. Can be overridden per table with the [`auto_flush_interval` table option](/reference/sql/create.md#table-options).                                                                                                                                                                                                                                                                                                                       |
| `global_write_buffer_size`               | String  | `1GB`         | Global write buffer size for all regions. If not set, it's default to 1/8 of OS memory with a max limitation of 1GB.                                                                                                                                                                                                                                                                                                                                                                               |
| `global_write_buffer_reject_size`        | String  | `2GB`         | Global write buffer size threshold to reject write requests. If not set, it's default to 2 times of `global_write_buffer_size`                                                                                                                                                                                                                                                                                                                                                                     |
| `default_region_write_buffer_size`       | String  | `0`           | Default per-region write buffer stall threshold. For a positive value, GreptimeDB schedules a flush when mutable memtable usage reaches half the value, stalls writes at the value, and rejects writes at twice the value. Setting it to `0` disables the default per-region limit. A table's `write_buffer_size` overrides this value, including an explicit `0` that disables the limit for that table.                                                                                                                                                              |
| `sst_meta_cache_size`                    | String  | Auto          | Cache size for SST metadata. Setting it to 0 to disable the cache.If not set, it's default to 1/8 of OS memory with a max limitation of 512MB.                                                                                                                                                                                                                                                                                                                                                |
| `vector_cache_size`                      | String  | `512MB`       | Cache size for vectors and arrow arrays. Setting it to 0 to disable the cache.If not set, it's default to 1/16 of OS memory with a max limitation of 512MB.                                                                                                                                                                                                                                                                                                                                   |
| `page_cache_size`                        | String  | `512MB`       | Cache size for pages of SST row groups. Setting it to 0 to disable the cache.If not set, it's default to 1/8 of OS memory.                                                                                                                                                                                                                                                                                                                                                                    |
| `write_cache_size`                       | String  | `5GiB`        | Capacity for write cache. If your disk space is sufficient, it is recommended to set it larger.                                                                                                                                                                                                                                                                                                                                                                                                    |
| `write_cache_ttl`                        | String  | `8h`          | TTL for write cache. Defaults to 8 hours.                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `preload_index_cache`                    | Bool    | `true`        | Preload index (puffin) files into cache on region open (default: true).When enabled, index files are loaded into the write cache during region initialization,which can improve query performance at the cost of longer startup times.                                                                                                                                                                                                                                                   |
| `index_cache_percent`                    | Integer | `20`          | Percentage of write cache capacity allocated for index (puffin) files (default: 20).The remaining capacity is used for data (parquet) files.Must be between 0 and 100 (exclusive). For example, with a 5GiB write cache and 20% allocation,1GiB is reserved for index files and 4GiB for data files.                                                                                                                                                                                |
| `enable_refill_cache_on_read`            | Bool    | `true`        | Enable refilling cache on read operations (default: true).When disabled, cache refilling on read won't happen.                                                                                                                                                                                                                                                                                                                                                                                |
| `manifest_cache_size`                    | String  | `256MB`       | Capacity for manifest cache (default: 256MB).                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `selector_result_cache_size`             | String  | `512MB`       | Cache size for time series selector (e.g. `last_value()`). Setting it to 0 to disable the cache.If not set, it's default to 1/16 of OS memory with a max limitation of 512MB.                                                                                                                                                                                                                                                                                                                 |
| `range_result_cache_size`                | String  | `512MB`       | Cache size for flat range scan results. Setting it to 0 to disable the cache.If not set, it's default to 1/16 of OS memory with a max limitation of 512MB.                                                                                                                                                                                                                                                                                                                                     |
| `prefilter_result_cache_size`            | String  | `128MB`       | Cache size for prefilter results. Setting it to 0 to disable the cache.If not set, it's default to 1/32 of OS memory with a max limitation of 128MB.                                                                                                                                                                                                                                                                                                                                           |
| `sst_write_buffer_size`                  | String  | `8MB`         | Buffer size for SST writing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `max_concurrent_scan_files`             | Integer | `384`         | Maximum number of SST files to scan concurrently.                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `allow_stale_entries`                 | Bool    | `false`      | Whether to allow stale WAL entries during replay.                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `scan_memory_limit`                   | String  | `unlimited`  | Memory limit for table scans across all queries. Supports absolute size (e.g., "2GB") or percentage of system memory (e.g., "20%"). Setting it to 0 or "unlimited" disables the limit.                                                                                                                                                                                                                           |
| `scan_memory_on_exhausted`           | String  | `fail`       | Behavior when scan memory is exhausted. Options: `fail` (fail fast), `wait` or `wait(<duration>)` (wait for memory).                                                                                                                                                                                                                                                 |
| `min_compaction_interval`           | String  | `0m`         | Minimum time interval between two compactions. Set to "0m" (default) to allow compactions to run immediately without restriction.                                                                                                                                                                                                                                             |
| `schedule_compaction_after_edit`    | Bool    | `true`       | Whether to allow scheduling a compaction after a successful region edit.Setting this to `true` is a necessary but not sufficient condition for scheduling compaction after a region edit. Other constraints, such as `min_compaction_interval`, may still prevent compaction from being scheduled.Setting this to `false` guarantees that compaction will not be scheduled after a region edit. |
| `default_flat_format`                | Bool    | `true`       | Whether Regions without an explicit `sst_format` use flat SSTs. Flat SSTs use the bulk memtable.                                                                                                                                                                                                                                                                      |
| `experimental_series_scan_v2`       | Bool    | `true`       | Whether to enable the experimental two-phase mode for series scans of metric engine physical regions. Set to `false` to use the legacy mode. Other series scans also use the legacy mode.                                                                                                                                                                                                                                           |
| `scan_parallelism`                       | Integer | `0`           | (Deprecated, use `max_concurrent_scan_files` instead) Legacy option for scan parallelism.                                                                                                                                                                                                                                                                                                              |
| `index`                                  | --      | --            | The options for index in Mito engine.                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `index.aux_path`                         | String  | `""`          | Auxiliary directory path for the index in the filesystem. This path is used to store intermediate files for creating the index and staging files for searching the index. It defaults to `{data_home}/index_intermediate`. The default name for this directory is `index_intermediate` for backward compatibility. This path contains two subdirectories: `__intm` for storing intermediate files used during index creation, and `staging` for storing staging files used during index searching. |
| `index.staging_size`                     | String  | `2GB`         | The maximum capacity of the staging directory.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `index.staging_ttl`                      | String  | `7d`          | TTL for staging directory. Defaults to 7 days. Setting to "0s" disables TTL.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `index.metadata_cache_size`              | String  | `64MiB`       | Cache size for index metadata.If not set, it's default to 1/32 of OS memory with a max limitation of 64MiB.                                                                                                                                                                                                                                                                                                                                                                                   |
| `index.content_cache_size`               | String  | `128MiB`      | Cache size for index content.If not set, it's default to 1/16 of OS memory with a max limitation of 128MiB.                                                                                                                                                                                                                                                                                                                                                                                   |
| `index.content_cache_page_size`          | String  | `64KiB`       | Page size for index content cache.                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `index.result_cache_size`                | String  | `128MiB`     | Cache size for index query results.If not set, it's default to 1/16 of OS memory with a max limitation of 128MiB.                                                                                                                                                                                                                                                                                                                                                                                |
| `inverted_index`                         | --      | --            | The options for inverted index in Mito engine.                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `inverted_index.create_on_flush`         | String  | `auto`        | Whether to create the index on flush.- `auto`: automatically- `disable`: never                                                                                                                                                                                                                                                                                                                                                                                                           |
| `inverted_index.create_on_compaction`    | String  | `auto`        | Whether to create the index on compaction.- `auto`: automatically- `disable`: never                                                                                                                                                                                                                                                                                                                                                                                                      |
| `inverted_index.apply_on_query`          | String  | `auto`        | Whether to apply the index on query- `auto`: automatically- `disable`: never                                                                                                                                                                                                                                                                                                                                                                                                             |
| `inverted_index.mem_threshold_on_create` | String  | `64M`         | Memory threshold for performing an external sort during index creation.Setting to empty will disable external sorting, forcing all sorting operations to happen in memory.                                                                                                                                                                                                                                                                                                                    |
| `inverted_index.intermediate_path`       | String  | `""`          | File system path to store intermediate files for external sorting (default `{data_home}/index_intermediate`).                                                                                                                                                                                                                                                                                                                                                                                      |

The `metric` engine is optimized for handling metrics data with a large number of small tables.

:::note
Starting from v1.2, sparse primary key encoding is always enabled for the metric engine and cannot be disabled. It encodes only non-null primary key columns, improving write and query performance. Any `sparse_primary_key_encoding` setting in your configuration file is accepted but has no effect.
:::

### Specify meta client

The `meta_client` options are valid in `datanode` and `frontend` mode, which specify the Metasrv client information.

```toml
metasrv_addrs = ["127.0.0.1:3002"]
timeout = "3s"
connect_timeout = "1s"
ddl_timeout = "10s"
tcp_nodelay = true
```

The `meta_client` configures the Metasrv client, including:

- `metasrv_addrs`: The Metasrv address list.
- `timeout`: operation timeout, `3s` by default.
- `connect_timeout`, connect server timeout, `1s` by default.
- `ddl_timeout`, DDL execution timeout, `10s` by default.
- `tcp_nodelay`, `TCP_NODELAY` option for accepted connections, true by default.

### Heartbeat configuration

In distributed mode, heartbeat intervals are controlled by Metasrv using the `heartbeat_interval` option.

```toml
# Metasrv-only option
heartbeat_interval = "3s"

# Top-level option for reporting selected env vars in heartbeat extensions
heartbeat_env_vars = ["AZ", "REGION"]
```

| Key                     | Type   | Default | Description                                                                                                                                                                                                                                                                                                                                                                                    |
| ----------------------- | ------ | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `heartbeat_interval`    | String | `3s`    | Metasrv base heartbeat interval. The frontend heartbeat interval is 6 times this value, and the datanode/flownode heartbeat interval is equal to this value. Heartbeat intervals are negotiated from Metasrv during handshake; local node configs do not override this.                                                                                                                    |
| `heartbeat_env_vars`    | Array  | `[]`    | A top-level option. Lists the environment variable keys to read at startup and report to Metasrv through heartbeat messages. The values are sent as heartbeat extensions and stored in Metasrv's node information. For example, `heartbeat_env_vars = ["AZ", "REGION"]` collects the `AZ` and `REGION` environment variables. **Do not include sensitive variables** (e.g., secrets or credentials), as their values will be transmitted to and stored in Metasrv. |

### Default time zone configuration

The `default_timezone` option is applicable in both `frontend` and `standalone` modes, with a default value of `UTC`.
It specifies the default client timezone for interactions with GreptimeDB.
If the time zone is [specified in the clients](/user-guide/timezone.md#specify-time-zone-in-clients), this option will be overridden for that client session.

```toml
default_timezone = "UTC"
```

The `default_timezone` value can be any named time zone, such as `Europe/Berlin` or `Asia/Shanghai`.
For information on how the client time zone affects data ingestion and querying,
refer to the [Time Zone](/user-guide/timezone.md#impact-of-time-zone-on-sql-statements) guide.

### Metasrv-only configuration

The `datanode.client` options configure outbound gRPC connections from Metasrv to Datanodes.
The client message size limits are independent of the `[grpc]` server message size limits.

```toml
# The working home directory.
data_home = "./greptimedb_data"
# Store server address default to etcd store.
# For postgres store, the format is:
# "password=password dbname=postgres user=postgres host=localhost port=5432"
# For mysql store, the format is:
# "mysql://user:password@ip:port/dbname"
# For etcd store, the format is:
# "127.0.0.1:2379"
store_addrs = ["127.0.0.1:2379"]
# If it's not empty, the metasrv will store all data with this key prefix.
store_key_prefix = ""
# The datastore for meta server.
# Available values:
# - `etcd_store` (default value)
# - `memory_store`
# - `postgres_store`
# - `mysql_store`
backend = "etcd_store"
# Table name in RDS to store metadata. Effect when using a RDS kvbackend.
# **Only used when backend is RDS kvbackend.**
meta_table_name = "greptime_metakv"
# 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`.
# **Only used when backend is `postgres_store`.**
meta_schema_name = "greptime_schema"
# Automatically create PostgreSQL schema if it doesn't exist.
# **Only used when backend is `postgres_store`.**
auto_create_schema = true
# Advisory lock id in PostgreSQL for election. Effect when using PostgreSQL as kvbackend
# Only used when backend is `postgres_store`.
meta_election_lock_id = 1
# Datanode selector type.
# - `round_robin` (default value)
# - `lease_based`
# - `load_based`
# For details, please see "https://docs.greptime.com/contributor-guide/metasrv/selector".
selector = "round_robin"
# Whether to enable region failover.
# This feature is only available on GreptimeDB running on cluster mode and:
# - Using Remote WAL, or Local WAL with `allow_region_failover_on_local_wal` set to `true`
# - Using shared storage (e.g., S3)
enable_region_failover = false
## The delay before starting region failure detection.
## This delay helps prevent Metasrv from triggering unnecessary region failovers before all Datanodes are fully started.
## Especially useful when the cluster is not deployed with GreptimeDB Operator and maintenance mode is not enabled.
region_failure_detector_initialization_delay = "10m"
# Whether to allow region failover on local WAL.
# **This option is not recommended to be set to true,
# because it may lead to data loss during failover.**
allow_region_failover_on_local_wal = false

## Max allowed idle time before removing node info from metasrv memory.
node_max_idle_time = "24hours"

# Base heartbeat interval for calculating distributed time constants.
# Heartbeat intervals are negotiated from metasrv during handshake; local node configs do not override this.
# heartbeat_interval = "3s"
# Whether to enable GreptimeDB telemetry. Enabled by default.
# enable_telemetry = true

# TLS configuration for kv store backend (applicable for etcd, PostgreSQL, and MySQL backends).
# If TLS is configured here and in `store_addrs`, this section overrides `store_addrs` TLS settings.
[backend_tls]
mode = "prefer"
cert_path = ""
key_path = ""
ca_cert_path = ""

## The backend client options.
## Currently, only applicable when using etcd as the metadata store.
[backend_client]
## The keep alive timeout for backend client.
keep_alive_timeout = "3s"
## The keep alive interval for backend client.
keep_alive_interval = "10s"
## The connect timeout for backend client.
connect_timeout = "3s"

## The gRPC server options.
[grpc]
bind_addr = "127.0.0.1:3002"
server_addr = "127.0.0.1:3002"
runtime_size = 8
## The maximum receive message size for gRPC server.
max_recv_message_size = "512MB"
## The maximum send message size for gRPC server.
max_send_message_size = "512MB"
## The server side HTTP/2 keep-alive interval
http2_keep_alive_interval = "10s"
## The server side HTTP/2 keep-alive timeout.
http2_keep_alive_timeout = "3s"

## The HTTP server options.
[http]
addr = "127.0.0.1:4000"
timeout = "0s"
body_limit = "64MB"
## Enable the dedicated public HTTP API server (serves /v1 and /dashboard only).
enable_api_server = false
api_server_addr = "127.0.0.1:4006"

## Procedure storage options.
[procedure]

## Procedure max retry time.
max_retry_times = 12

## Initial retry delay of procedures, increases exponentially
retry_delay = "500ms"

## Auto split large values.
max_metadata_value_size = "1500KiB"

## Max running procedures.
## The maximum number of procedures that can be running at the same time.
## If the number of running procedures exceeds this limit, the procedure will be rejected.
max_running_procedures = 128

# Failure detectors options.
# GreptimeDB uses the Phi Accrual Failure Detector algorithm to detect datanode failures.
[failure_detector]

## Maximum acceptable φ before the peer is treated as failed.
## Lower values react faster but yield more false positives.
threshold = 8.0

## The minimum standard deviation of the heartbeat intervals.
## So tiny variations don't make φ explode. Prevents hypersensitivity when heartbeat intervals barely vary.
min_std_deviation = "100ms"

## The acceptable pause duration between heartbeats.
## Additional extra grace period to the learned mean interval before φ rises, absorbing temporary network hiccups or GC pauses.
acceptable_heartbeat_pause = "10000ms"

## Datanode options.
[datanode]

## Datanode client options.
[datanode.client]

## Operation timeout.
timeout = "10s"

## Connect server timeout.
connect_timeout = "10s"

## `TCP_NODELAY` option for accepted connections.
tcp_nodelay = true

## The maximum receive message size for the gRPC client.
max_recv_message_size = "512MB"

## The maximum send message size for the gRPC client.
max_send_message_size = "512MB"

[wal]
# Available wal providers:
# - `raft_engine` (default): there're none raft-engine wal config since metasrv only involves in remote wal currently.
# - `kafka`: metasrv **have to be** configured with kafka wal config when using kafka wal provider in datanode.
provider = "raft_engine"

# Kafka wal config.

## The broker endpoints of the Kafka cluster.
broker_endpoints = ["127.0.0.1:9092"]

## Automatically create topics for WAL.
## Set to `true` to automatically create topics for WAL.
## Otherwise, use topics named `topic_name_prefix_[0..num_topics)`
auto_create_topics = true

## Number of topics.
num_topics = 64

## Topic selector type.
## Available selector types:
## - `round_robin` (default)
selector_type = "round_robin"

## A Kafka topic is constructed by concatenating `topic_name_prefix` and `topic_id`.
topic_name_prefix = "greptimedb_wal_topic"

## Expected number of replicas of each partition.
replication_factor = 1

## Above which a topic creation operation will be cancelled.
create_topic_timeout = "30s"

## The connect timeout for kafka client.
## **It's only used when the provider is `kafka`**.
connect_timeout = "3s"

## The timeout for kafka client.
## **It's only used when the provider is `kafka`**.
timeout = "3s"

# The Kafka SASL configuration.
# **It's only used when the provider is `kafka`**.
# Available SASL mechanisms:
# - `PLAIN`
# - `SCRAM-SHA-256`
# - `SCRAM-SHA-512`
# [wal.sasl]
# type = "SCRAM-SHA-512"
# username = "user_kafka"
# password = "secret"

# The Kafka TLS configuration.
# **It's only used when the provider is `kafka`**.
# [wal.tls]
# server_ca_cert_path = "/path/to/server_cert"
# client_cert_path = "/path/to/client_cert"
# client_key_path = "/path/to/key"

```

| Key                                           | Type    | Default                      | Descriptions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------------------------------- | ------- | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `data_home`                                   | String  | `./greptimedb_data/metasrv/` | The working home directory.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `bind_addr`                                   | String  | `127.0.0.1:3002`             | The bind address of metasrv.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `server_addr`                                 | String  | `127.0.0.1:3002`             | The communication server address for frontend and datanode to connect to metasrv, "127.0.0.1:3002" by default for localhost.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `store_addrs`                                 | Array   | `["127.0.0.1:2379"]`         | Store server address. Configure the address based on your backend type, for example:- Use `127.0.0.1:2379` to connect to etcd- Use `"password=password dbname=postgres user=postgres host=localhost port=5432"` to connect to postgres- Use `"mysql://user:password@ip:port/dbname"` to connect to mysql                                                                                                                                                                                                                                                                                               |
| `selector`                                    | String  | `round_robin`                | Datanode selector type.- `round_robin` (default value)- `lease_based`- `load_based`For details, see [Selector](/contributor-guide/metasrv/selector.md)                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `enable_region_failover`                      | Bool    | `false`                      | Whether to enable region failover.This feature is only available on GreptimeDB running on cluster mode and:- Using Remote WAL, or Local WAL with `allow_region_failover_on_local_wal` set to `true`- Using shared storage (e.g., S3).                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `region_failure_detector_initialization_delay` | String  | `10m`                        | The delay before starting region failure detection. This delay helps prevent Metasrv from triggering unnecessary region failovers before all Datanodes are fully started. Especially useful when the cluster is not deployed with GreptimeDB Operator and maintenance mode is not enabled. |
| `allow_region_failover_on_local_wal`          | Bool    | `false`                      | Whether to allow region failover on local WAL.**This option is not recommended to be set to true, because it may lead to data loss during failover.**                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `node_max_idle_time`                          | String  | `24hours`                    | Max allowed idle time before removing node info from metasrv memory. Nodes that haven't sent heartbeats for this duration will be considered inactive and removed.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `backend_tls`                                 | --      | --                           | TLS configuration for kv store backend. Applicable for etcd, PostgreSQL, and MySQL backends. If TLS is configured here and in `store_addrs`, this section overrides `store_addrs` TLS settings. |
| `backend_tls.mode`                            | String  | `prefer`                     | TLS mode for the kv store backend. Options are `disable`, `prefer`, `require`, `verify_ca`, and `verify_full`. |
| `backend_tls.cert_path`                       | String  | --                           | File path for the client TLS certificate. |
| `backend_tls.key_path`                        | String  | --                           | File path for the client TLS private key. |
| `backend_tls.ca_cert_path`                    | String  | --                           | File path for the trusted CA certificate. |
| `backend_client`                              | --      | --                           | The backend client options.Currently, only applicable when using etcd as the metadata store.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `backend_client.keep_alive_timeout`           | String  | `3s`                         | The keep alive timeout for backend client.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `backend_client.keep_alive_interval`          | String  | `10s`                        | The keep alive interval for backend client.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `backend_client.connect_timeout`              | String  | `3s`                         | The connect timeout for backend client.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `grpc`                                        | --      | --                           | The gRPC server options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `grpc.bind_addr`                              | String  | `127.0.0.1:3002`             | The address to bind the gRPC server.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `grpc.server_addr`                            | String  | `127.0.0.1:3002`             | The communication server address for frontend and datanode to connect to metasrv.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `grpc.runtime_size`                           | Integer | `8`                          | The number of server worker threads. |
| `grpc.max_recv_message_size`                  | String  | `512MB`                      | The maximum receive message size for the gRPC server. |
| `grpc.max_send_message_size`                  | String  | `512MB`                      | The maximum send message size for the gRPC server.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `grpc.http2_keep_alive_interval`              | String  | `10s`                        | The server side HTTP/2 keep-alive interval.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `grpc.http2_keep_alive_timeout`               | String  | `3s`                         | The server side HTTP/2 keep-alive timeout. |
| `http`                                        | --      | --                           | HTTP server options. |
| `http.addr`                                   | String  | `127.0.0.1:4000`             | HTTP server address. |
| `http.timeout`                                | String  | `0s`                         | HTTP request timeout. Set to `0s` to disable timeout. |
| `http.body_limit`                             | String  | `64MB`                       | HTTP max body size.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `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. |
| `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`. |
| `backend`                                     | String  | `etcd_store`                 | The datastore for metasrv.- `etcd_store` (default)- `memory_store` (In memory metadata storage - only used for testing.)- `postgres_store`- `mysql_store`                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `meta_table_name`                             | String  | `greptime_metakv`            | Table name in RDS to store metadata. Effect when using a RDS kvbackend.**Only used when backend is RDS kvbackend.**                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `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`.**Only used when backend is `postgres_store`.**                                                                                                                                                                                                                                                                                           |
| `auto_create_schema`                          | Bool    | `true`                       | Automatically create PostgreSQL schema if it doesn't exist. When enabled, the system will execute `CREATE SCHEMA IF NOT EXISTS <schema_name>` before creating metadata tables. This is useful in production environments where manual schema creation may be restricted. Note: The PostgreSQL user must have CREATE SCHEMA permission for this to work.**Only used when backend is `postgres_store`.**                                                                                                                                                                                                           |
| `meta_election_lock_id`                       | Integer | `1`                          | Advisory lock id in PostgreSQL for election. Effect when using PostgreSQL as kvbackend**Only used when backend is `postgres_store`.**                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `procedure`                                   | --      | --                           | Procedure storage options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `procedure.max_retry_times`                   | Integer | `12`                         | Procedure max retry time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `procedure.retry_delay`                       | String  | `500ms`                      | Initial retry delay of procedures, increases exponentially. |
| `procedure.max_metadata_value_size`           | String  | `1500KiB`                    | Maximum size of a procedure metadata value before it is split into multiple backend entries.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `procedure.max_running_procedures`            | Integer | `128`                        | The maximum number of procedures that can be running at the same time. If the number of running procedures exceeds this limit, the procedure will be rejected.                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `failure_detector`                            | --      | --                           | --                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `failure_detector.threshold`                  | Float   | `8.0`                        | Maximum acceptable φ before the peer is treated as failed.Lower values react faster but yield more false positives.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `failure_detector.min_std_deviation`          | String  | `100ms`                      | The minimum standard deviation of the heartbeat intervals.So tiny variations don't make φ explode. Prevents hypersensitivity when heartbeat intervals barely vary.                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `failure_detector.acceptable_heartbeat_pause` | String  | `10000ms`                    | The acceptable pause duration between heartbeats.Additional extra grace period to the learned mean interval before φ rises, absorbing temporary network hiccups or GC pauses.                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `datanode`                                    | --      | --                           | Datanode options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `datanode.client`                             | --      | --                           | Datanode client options.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `datanode.client.timeout`                     | String  | `10s`                        | Operation timeout.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `datanode.client.connect_timeout`             | String  | `10s`                        | Connect server timeout.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `datanode.client.tcp_nodelay`                 | Bool    | `true`                       | `TCP_NODELAY` option for accepted connections.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `datanode.client.max_recv_message_size`       | String  | `512MB`                      | The maximum receive message size for the gRPC client.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `datanode.client.max_send_message_size`       | String  | `512MB`                      | The maximum send message size for the gRPC client.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `wal`                                         | --      | --                           | --                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `wal.provider`                                | String  | `raft_engine`                | --                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `wal.broker_endpoints`                        | Array   | --                           | The broker endpoints of the Kafka cluster.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `wal.auto_prune_interval`                     | String  | `0s`                         | Interval of automatically WAL pruning.Set to `0s` to disable automatically WAL pruning which delete unused remote WAL entries periodically.                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `wal.trigger_flush_threshold`                 | Integer | `0`                          | The threshold to trigger a flush operation of a region in automatically WAL pruning.Metasrv will send a flush request to flush the region when:`trigger_flush_threshold` + `prunable_entry_id` < `max_prunable_entry_id`where:- `prunable_entry_id` is the maximum entry id that can be pruned of the region. Entries before `prunable_entry_id` are not used by this region.- `max_prunable_entry_id` is the maximum prunable entry id among all regions in the same topic. Entries before `max_prunable_entry_id` are not used by any region.Set to `0` to disable the flush operation. |
| `wal.auto_prune_parallelism`                  | Integer | `10`                         | Concurrent task limit for automatically WAL pruning. Each task is responsible for WAL pruning for a kafka topic.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `wal.num_topics`                              | Integer | `64`                         | Number of topics.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `wal.selector_type`                           | String  | `round_robin`                | Topic selector type.Available selector types:- `round_robin` (default)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `wal.topic_name_prefix`                       | String  | `greptimedb_wal_topic`       | A Kafka topic is constructed by concatenating `topic_name_prefix` and `topic_id`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `wal.replication_factor`                      | Integer | `1`                          | Expected number of replicas of each partition.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `wal.create_topic_timeout`                    | String  | `30s`                        | Above which a topic creation operation will be cancelled.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| `wal.connect_timeout`                         | String  | `3s`                         | The connect timeout for kafka client.**It's only used when the provider is `kafka`**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `wal.timeout`                                 | String  | `3s`                         | The timeout for kafka client.**It's only used when the provider is `kafka`**.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `wal.sasl`                                    | String  | --                           | The Kafka SASL configuration.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `wal.sasl.type`                               | String  | --                           | The SASL mechanisms, available values: `PLAIN`, `SCRAM-SHA-256`, `SCRAM-SHA-512`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `wal.sasl.username`                           | String  | --                           | The SASL username.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `wal.sasl.password`                           | String  | --                           | The SASL password.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| `wal.tls`                                     | String  | --                           | The Kafka TLS configuration.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `wal.tls.server_ca_cert_path`                 | String  | --                           | The path of trusted server ca certs.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `wal.tls.client_cert_path`                    | String  | --                           | The path of client cert (Used for enable mTLS).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `wal.tls.client_key_path`                     | String  | --                           | The path of client key (Used for enable mTLS).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |

### Datanode-only configuration

```toml
node_id = 42
[grpc]
bind_addr = "127.0.0.1:3001"
server_addr = "127.0.0.1:3001"
runtime_size = 8

[runtime]
query_rt_size = 7
ingest_rt_size = 8
```

| Key               | Type    | Description                                                                                                                                                                                                                                                                     |
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| node_id           | Integer | The datanode identifier, should be unique.                                                                                                                                                                                                                                      |
| grpc.bind_addr    | String  | The address to bind the gRPC server, `127.0.0.1:3001` by default.                                                                                                                                                                                                             |
| grpc.server_addr  | String  | The address advertised to the metasrv, and used for connections from outside the host. If left empty or unset, the server will automatically use the IP address of the first network interface on the host, with the same port number as the one specified in `grpc.bind_addr`. |
| grpc.runtime_size | Integer | The number of gRPC server worker threads, 8 by default.                                                                                                                                                                                                                         |
| runtime.query_rt_size | Integer | The number of threads to execute datanode query operations. Defaults to `max(num_cpus - 1, 1)`. |
| runtime.ingest_rt_size | Integer | The number of threads to execute datanode ingestion operations. Defaults to the number of CPU cores. |

For the common runtime options shared by all components, see [Runtime options](#runtime-options).

### Frontend-only configuration

The `datanode.client` options configure outbound gRPC connections from Frontend to Datanodes.
The client message size limits are independent of the `[grpc]` server message size limits.

```toml
[datanode]
[datanode.client]
connect_timeout = "1s"
tcp_nodelay = true
max_recv_message_size = "512MB"
max_send_message_size = "512MB"
```

| Key                                             | Type   | Default | Description                                            |
| ----------------------------------------------- | ------ | ------- | ------------------------------------------------------ |
| `datanode`                                      | --     | --      | Datanode options.                                      |
| `datanode.client`                               | --     | --      | Datanode client options.                               |
| `datanode.client.connect_timeout`               | String | `1s`    | Connect server timeout.                                |
| `datanode.client.tcp_nodelay`                   | Bool   | `true`  | `TCP_NODELAY` option for accepted connections.         |
| `datanode.client.max_recv_message_size`         | String | `512MB` | The maximum receive message size for the gRPC client.  |
| `datanode.client.max_send_message_size`         | String | `512MB` | The maximum send message size for the gRPC client.     |
