diff --git a/docs/user-guide/deployments-administration/configuration.md b/docs/user-guide/deployments-administration/configuration.md index 96748f766..16cf9706e 100644 --- a/docs/user-guide/deployments-administration/configuration.md +++ b/docs/user-guide/deployments-administration/configuration.md @@ -185,6 +185,9 @@ 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" [prom_store] enable = true @@ -216,6 +219,7 @@ The following table describes the options in detail: | | runtime_size | Integer | The number of server worker threads, 2 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 | | prom_store | | | Prometheus remote storage options | diff --git a/docs/user-guide/deployments-administration/performance-tuning/design-table.md b/docs/user-guide/deployments-administration/performance-tuning/design-table.md index 462757ba7..764699d82 100644 --- a/docs/user-guide/deployments-administration/performance-tuning/design-table.md +++ b/docs/user-guide/deployments-administration/performance-tuning/design-table.md @@ -318,8 +318,8 @@ allowing updates to provide only the values that need to change. ![merge-mode-last-non-null](/merge-mode-last-non-null.png) -The `last_non_null` merge mode is the default for tables created automatically via the InfluxDB line protocol, -aligning with InfluxDB's update behavior. +For tables created automatically via the InfluxDB line protocol, the default merge mode comes from the [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) configuration, which defaults to `last_non_null` to align with InfluxDB's update behavior. +An explicit HTTP `merge_mode` hint in the write request takes precedence over the configured default. If an InfluxDB line protocol write explicitly sets the HTTP `append_mode` hint to `true`, the auto-created table uses `append_mode = 'true'` and `merge_mode = 'last_row'` instead. diff --git a/docs/user-guide/ingest-data/for-iot/influxdb-line-protocol.md b/docs/user-guide/ingest-data/for-iot/influxdb-line-protocol.md index 011aca995..bead74709 100644 --- a/docs/user-guide/ingest-data/for-iot/influxdb-line-protocol.md +++ b/docs/user-guide/ingest-data/for-iot/influxdb-line-protocol.md @@ -59,7 +59,15 @@ curl -i -XPOST "http://localhost:4000/v1/influxdb/write?db=public&precision=ms&u ``` When `append_mode=true` is explicitly provided, GreptimeDB creates the table with `append_mode = 'true'` and `merge_mode = 'last_row'`. -If the hint is absent or set to `false`, auto-created InfluxDB line protocol tables keep the default `merge_mode = 'last_non_null'`. +Otherwise, auto-created InfluxDB line protocol tables use the merge mode from the `merge_mode` HTTP hint. If no hint is provided, GreptimeDB uses the configured [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) value, which defaults to `last_non_null`. +To change the cluster-wide default for InfluxDB line protocol auto-created tables, set this option in the standalone or frontend configuration file: + +```toml +[influxdb] +default_merge_mode = "last_row" +``` + +Available values are `last_non_null` and `last_row`. You can also omit the timestamp when sending requests. GreptimeDB will use the current system time (in UTC) of the host machine as the timestamp. For example: @@ -161,8 +169,8 @@ While you may already be familiar with [InfluxDB key concepts](https://docs.infl Here are the similarities and differences between the data models of GreptimeDB and InfluxDB: - Both solutions are [schemaless](/user-guide/ingest-data/overview.md#automatic-schema-generation), eliminating the need to define a schema before writing data. -- The GreptimeDB table is automatically created with the [`merge_mode` option](/reference/sql/create.md#create-a-table-with-merge-mode) set to `last_non_null` by default. - That means the table merges rows with the same tags and timestamp by keeping the latest value of each field, which is the same behavior as InfluxDB. +- The GreptimeDB table is automatically created with the [`merge_mode` option](/reference/sql/create.md#create-a-table-with-merge-mode) set from the `merge_mode` HTTP hint or from [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) when the hint is absent. The configuration defaults to `last_non_null`. + With `last_non_null`, the table merges rows with the same tags and timestamp by keeping the latest value of each field, which is the same behavior as InfluxDB. If the request explicitly sets the HTTP `append_mode` hint to `true`, the table is created with `append_mode = 'true'` and `merge_mode = 'last_row'`. - In InfluxDB, a point represents a single data record with a measurement, tag set, field set, and a timestamp. In GreptimeDB, it is represented as a row of data in the time-series table, diff --git a/docs/user-guide/protocols/http.md b/docs/user-guide/protocols/http.md index b935a4fcc..3fa857acc 100644 --- a/docs/user-guide/protocols/http.md +++ b/docs/user-guide/protocols/http.md @@ -89,8 +89,8 @@ Supported hints: | --- | --- | --- | --- | | `auto_create_table` | Boolean | `true` | Whether to automatically create the table if it does not exist when inserting data. | | `ttl` | Duration string | None | Sets the [time-to-live](/user-guide/manage-data/overview.md#manage-data-retention-with-ttl-policies) for the table, e.g. `7d`, `24h`. Expired data will be automatically purged. | -| `append_mode` | Boolean | `false` | Enables [append-only mode](/reference/sql/create.md#create-an-append-only-table) for the table, which disables deduplication by primary key and supports duplicate rows. For InfluxDB line protocol writes, an explicit `append_mode=true` hint creates the table with `append_mode = 'true'` and `merge_mode = 'last_row'`; an absent or `false` hint keeps the default `merge_mode = 'last_non_null'`. | -| `merge_mode` | String | None | Sets the [merge mode](/reference/sql/create.md#create-a-table-with-merge-mode) for the table, e.g. `last_non_null`, `last_row`. When `append_mode` is enabled, only `last_row` is allowed. | +| `append_mode` | Boolean | `false` | Enables [append-only mode](/reference/sql/create.md#create-an-append-only-table) for the table, which disables deduplication by primary key and supports duplicate rows. For InfluxDB line protocol writes, an explicit `append_mode=true` hint creates the table with `append_mode = 'true'` and `merge_mode = 'last_row'`. | +| `merge_mode` | String | None | Sets the [merge mode](/reference/sql/create.md#create-a-table-with-merge-mode) for the table, e.g. `last_non_null`, `last_row`. For auto-created InfluxDB line protocol tables, this hint takes precedence over [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md), which defaults to `last_non_null`. When `append_mode` is enabled, only `last_row` is allowed. | | `physical_table` | String | None | Specifies the physical table name for the [metric engine](/contributor-guide/datanode/metric-engine.md). | | `skip_wal` | Boolean | `false` | Skips WAL (Write-Ahead Log) writes for the table. | | `sst_format` | String | None | Sets the SST (Sorted String Table) file format for the table. Valid values: `flat`, `primary_key`. | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/configuration.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/configuration.md index 121a72fac..1bedd281f 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/configuration.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/configuration.md @@ -178,6 +178,9 @@ enable = true [influxdb] enable = true +# InfluxDB 协议自动创建表时使用的默认 merge 模式。 +# 可选值:"last_non_null"、"last_row"。 +default_merge_mode = "last_non_null" [prom_store] enable = true @@ -209,6 +212,7 @@ max_inflight_requests = 3000 | | runtime_size | 整数 | 服务器工作线程数量,默认为 2 | | influxdb | | | InfluxDB 协议选项 | | | enable | 布尔值 | 是否在 HTTP API 中启用 InfluxDB 协议,默认为 true | +| | default_merge_mode | 字符串 | InfluxDB 协议自动创建表时使用的默认 merge 模式。可选值:`last_non_null`、`last_row`。默认值:`last_non_null` | | opentsdb | | | OpenTSDB 协议选项 | | | enable | 布尔值 | 是否启用 OpenTSDB 协议,默认为 true | | prom_store | | | Prometheus 远程存储选项 | diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/design-table.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/design-table.md index 25a8b7132..346ba3660 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/design-table.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/deployments-administration/performance-tuning/design-table.md @@ -311,7 +311,8 @@ GreptimeDB 使用基于 LSM-Tree 的存储引擎, ![merge-mode-last-non-null](/merge-mode-last-non-null.png) -为了与 InfluxDB 的更新行为一致,通过 InfluxDB line protocol 自动创建的表默认启用 `last_non_null` 合并模式。 +对于通过 InfluxDB line protocol 自动创建的表,默认 merge 模式来自 [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) 配置;该配置默认值为 `last_non_null`,以便与 InfluxDB 的更新行为保持一致。 +写入请求中显式设置的 HTTP `merge_mode` hint 优先于配置中的默认值。 如果 InfluxDB 行协议写入显式将 HTTP `append_mode` hint 设置为 `true`, 自动创建的表会改为使用 `append_mode = 'true'` 和 `merge_mode = 'last_row'`。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/influxdb-line-protocol.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/influxdb-line-protocol.md index 42a4cdc13..bb0e53be1 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/influxdb-line-protocol.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/ingest-data/for-iot/influxdb-line-protocol.md @@ -59,7 +59,15 @@ curl -i -XPOST "http://localhost:4000/v1/influxdb/write?db=public&precision=ms&u ``` 当显式提供 `append_mode=true` 时,GreptimeDB 会使用 `append_mode = 'true'` 和 `merge_mode = 'last_row'` 创建表。 -如果未提供该 hint 或将其设为 `false`,通过 InfluxDB 行协议自动创建的表会继续使用默认的 `merge_mode = 'last_non_null'`。 +否则,通过 InfluxDB 行协议自动创建的表会使用 HTTP `merge_mode` hint 指定的 merge 模式。如果未提供该 hint,GreptimeDB 会使用配置项 [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) 的值,该配置默认值为 `last_non_null`。 +如需修改通过 InfluxDB 行协议自动创建表时使用的集群级默认值,请在 standalone 或 frontend 配置文件中设置该选项: + +```toml +[influxdb] +default_merge_mode = "last_row" +``` + +可选值为 `last_non_null` 和 `last_row`。 你还可以在发送请求时省略 timestamp,GreptimeDB 将使用主机机器的当前系统时间(UTC 时间)作为 timestamp。例如: @@ -162,8 +170,8 @@ GreptimeDB 的[数据模型](/user-guide/concepts/data-model.md) 是值得了解 下方解释了 GreptimeDB 和 InfluxDB 数据模型的相似和不同之处: - 两者都是 [schemaless 写入](/user-guide/ingest-data/overview.md#自动生成表结构)的解决方案,这意味着在写入数据之前无需定义表结构。 -- GreptimeDB 的表在自动创建时默认会设置表选项 [`merge_mode`](/reference/sql/create.md#创建带有-merge-模式的表)为 `last_non_null`。 - 这意味着表会通过保留每个字段的最新值来合并具有相同主键和时间戳的行,该行为与 InfluxDB 相同。 +- GreptimeDB 自动创建表时,会根据 HTTP `merge_mode` hint 或(未提供该 hint 时)[`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) 配置设置 [`merge_mode` 选项](/reference/sql/create.md#创建带有-merge-模式的表)。该配置默认值为 `last_non_null`。 + 使用 `last_non_null` 时,表会通过保留每个字段的最新值来合并具有相同主键和时间戳的行,该行为与 InfluxDB 相同。 如果请求显式将 HTTP `append_mode` hint 设置为 `true`,则会使用 `append_mode = 'true'` 和 `merge_mode = 'last_row'` 创建表。 - 在 InfluxDB 中,一个点代表一条数据记录,包含一个 measurement、tag 集、field 集和时间戳。 在 GreptimeDB 中,它被表示为时间序列表中的一行数据。 diff --git a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/http.md b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/http.md index 57a5501f0..c57dd7cef 100644 --- a/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/http.md +++ b/i18n/zh/docusaurus-plugin-content-docs/current/user-guide/protocols/http.md @@ -83,8 +83,8 @@ x-greptime-hint-key2: value2 | --- | --- | --- | --- | | `auto_create_table` | Boolean | `true` | 插入数据时,如果表不存在是否自动创建。 | | `ttl` | 时间字符串 | 无 | 设置表的[数据过期时间](/user-guide/manage-data/overview.md#使用-ttl-策略保留数据),例如 `7d`、`24h`。过期数据将被自动清理。 | -| `append_mode` | Boolean | `false` | 启用表的 [append-only 模式](/reference/sql/create.md#创建-append-only-表),该模式禁用按主键去重,支持重复行。对于 InfluxDB 行协议写入,显式设置 `append_mode=true` hint 时,会使用 `append_mode = 'true'` 和 `merge_mode = 'last_row'` 创建表;未设置该 hint 或设置为 `false` 时,则保留默认的 `merge_mode = 'last_non_null'`。 | -| `merge_mode` | String | 无 | 设置表的 [merge 模式](/reference/sql/create.md#创建带有-merge-模式的表),例如 `last_non_null`、`last_row`。启用 `append_mode` 时,仅允许使用 `last_row`。 | +| `append_mode` | Boolean | `false` | 启用表的 [append-only 模式](/reference/sql/create.md#创建-append-only-表),该模式禁用按主键去重,支持重复行。对于 InfluxDB 行协议写入,显式设置 `append_mode=true` hint 时,会使用 `append_mode = 'true'` 和 `merge_mode = 'last_row'` 创建表。 | +| `merge_mode` | String | 无 | 设置表的 [merge 模式](/reference/sql/create.md#创建带有-merge-模式的表),例如 `last_non_null`、`last_row`。对于通过 InfluxDB 行协议自动创建的表,该 hint 优先于 [`influxdb.default_merge_mode`](/user-guide/deployments-administration/configuration.md) 配置;该配置默认值为 `last_non_null`。启用 `append_mode` 时,仅允许使用 `last_row`。 | | `physical_table` | String | 无 | 指定 [metric 引擎](/contributor-guide/datanode/metric-engine.md)的物理表名。 | | `skip_wal` | Boolean | `false` | 跳过表的 WAL(Write-Ahead Log)写入。 | | `sst_format` | String | 无 | 设置表的 SST(Sorted String Table)文件格式。可选值:`flat`、`primary_key`。 |