You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by gi...@apache.org on 2026/09/10 15:58:18 UTC

(seatunnel) 01/01: [Docs][Connector-V2] Improve Aerospike Feishu Mysql GraphQL and Prometheus connector docs (#11794)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-11794-a1135fd445fa4897db6d95472d333c9c0aa47e84
in repository https://gitbox.apache.org/repos/asf/seatunnel.git

commit 52bb0d56110510df28ff1d4ca698cf08cfeacf8c
Author: Daniel Carter <80...@qq.com>
AuthorDate: Thu Sep 10 15:43:43 2026 +0000

    [Docs][Connector-V2] Improve Aerospike Feishu Mysql GraphQL and Prometheus connector docs (#11794)
    
    Co-authored-by: DanielCarter-stack <da...@gmail.com>
    Co-authored-by: DanielCarter-stack <Da...@users.noreply.github.com>
---
 docs/en/connectors/source/Prometheus.md |  5 +-
 docs/zh/connectors/sink/Aerospike.md    | 10 ++--
 docs/zh/connectors/sink/Feishu.md       | 97 ++++++++++++++++++++++++++++++++-
 docs/zh/connectors/sink/Mysql.md        |  8 +--
 docs/zh/connectors/source/GraphQL.md    | 90 ++++++++++++++++++++++++++++++
 docs/zh/connectors/source/Prometheus.md | 70 ++++++++++++++++++++++++
 6 files changed, 267 insertions(+), 13 deletions(-)

diff --git a/docs/en/connectors/source/Prometheus.md b/docs/en/connectors/source/Prometheus.md
index 2515ba03de..a34f23cdc5 100644
--- a/docs/en/connectors/source/Prometheus.md
+++ b/docs/en/connectors/source/Prometheus.md
@@ -161,8 +161,9 @@ source {
 ## Streaming Range Query Example
 
 Run a range query continuously against a Prometheus or VictoriaMetrics server. The
-source re-runs the same range query every `poll_interval_millis` and forwards the
-newest samples to downstream operators.
+source re-runs the same fixed time-window query every `poll_interval_millis`.
+`start` and `end` are resolved when the job starts, so the time window does not
+advance between polls.
 
 ```hocon
 env {
diff --git a/docs/zh/connectors/sink/Aerospike.md b/docs/zh/connectors/sink/Aerospike.md
index fd409a679f..65c4ac23ce 100644
--- a/docs/zh/connectors/sink/Aerospike.md
+++ b/docs/zh/connectors/sink/Aerospike.md
@@ -4,17 +4,17 @@ import ChangeLog from '../changelog/connector-aerospike.md';
 
 > Aerospike 数据写入连接器
 
-## 许可证兼容性通知
-
-此连接器依赖于根据AGPL 3.0许可的Aerospike客户端库。
-使用此连接器时,您需要遵守AGPL 3.0许可条款。
-
 ## 支持引擎
 
 > Spark<br/>
 > Flink<br/>
 > Seatunnel Zeta<br/>
 
+## 许可证兼容性通知
+
+此连接器依赖于根据AGPL 3.0许可的Aerospike客户端库。
+使用此连接器时,您需要遵守AGPL 3.0许可条款。
+
 ## 主要特性
 
 - [ ] [精确一次](../../introduction/concepts/connector-v2-features.md)
diff --git a/docs/zh/connectors/sink/Feishu.md b/docs/zh/connectors/sink/Feishu.md
index 6aa3b35a05..e0735cb579 100644
--- a/docs/zh/connectors/sink/Feishu.md
+++ b/docs/zh/connectors/sink/Feishu.md
@@ -47,7 +47,9 @@ import ChangeLog from '../changelog/connector-http-feishu.md';
 | DECIMAL                     | BigDecimal |
 | BYTES                       | byte[]     |
 | STRING                      | String     |
-| TIME<br/>TIMESTAMP<br/>TIME | String     |
+| DATE                        | String     |
+| TIME                        | String     |
+| TIMESTAMP                   | String     |
 | ARRAY                       | JsonArray  |
 
 ## 接收器选项
@@ -86,7 +88,7 @@ env {
 
 source {
   FakeSource {
-    row_num = 1
+    row.num = 1
     schema = {
       fields {
         name = string
@@ -143,6 +145,97 @@ Feishu {
 }
 ```
 
+### 流式告警推送到飞书机器人
+
+如果需要持续推送告警,可以把 Sink 运行在流模式下,并配合 `request_interval_ms`
+和 `array_mode = true`,把多条告警合并成一次 Webhook 调用。下面的示例从 Kafka
+主题读取事件,并按批次以 JSON 数组的形式发送。
+
+```hocon
+env {
+  parallelism = 1
+  job.mode = "STREAMING"
+  checkpoint.interval = 30000
+}
+
+source {
+  Kafka {
+    plugin_output = "alerts"
+    bootstrap.servers = "kafka:9092"
+    topic = "service_alerts"
+    format = "json"
+    schema = {
+      fields {
+        name = string
+        age = int
+      }
+    }
+  }
+}
+
+sink {
+  Feishu {
+    plugin_input = "alerts"
+    url = "https://open.feishu.cn/open-apis/bot/v2/hook/<your-hook-token>"
+    array_mode = true
+    batch_size = 20
+    request_interval_ms = 1000
+    retry = 5
+    retry_backoff_multiplier_ms = 200
+    retry_backoff_max_ms = 10000
+  }
+}
+```
+
+### 发送飞书富文本消息
+
+飞书机器人 Webhook 接收的是 `msg_type` 包裹的消息,例如 `text`、`post` 或
+`interactive`。可以在上游加一个 Transform,把每一行包装成期望的格式后再交给
+飞书 Sink 发送。下面的示例把每行数据封装成 `text` 消息体。
+
+```hocon
+env {
+  parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  FakeSource {
+    plugin_output = "raw"
+    row.num = 1
+    schema = {
+      fields {
+        name = string
+        age = int
+      }
+    }
+    rows = [
+      {
+        fields = [tyrantlucifer, 12]
+        kind = INSERT
+      }
+    ]
+  }
+}
+
+transform {
+  Sql {
+    plugin_input = "raw"
+    query = "SELECT 'text' AS msg_type, named_struct('text', concat('User ', name, ' is ', cast(age as string), ' years old')) AS content FROM raw"
+  }
+}
+
+sink {
+  Feishu {
+    plugin_input = "Sql"
+    url = "https://open.feishu.cn/open-apis/bot/v2/hook/<your-hook-token>"
+    headers {
+      Content-Type = "application/json"
+    }
+  }
+}
+```
+
 ## 变更日志
 
 <ChangeLog />
diff --git a/docs/zh/connectors/sink/Mysql.md b/docs/zh/connectors/sink/Mysql.md
index 75b7648d6c..d38f17c7ca 100644
--- a/docs/zh/connectors/sink/Mysql.md
+++ b/docs/zh/connectors/sink/Mysql.md
@@ -83,17 +83,17 @@ import ChangeLog from '../changelog/connector-jdbc.md';
 | batch_interval_ms            | Long    | 否       | 0                            | 写入触发的定时刷新间隔,单位毫秒。`0` 表示关闭定时刷新;大于 0 时,写入器会在每条记录写入时检查间隔,达到间隔后同步刷新。                                                           |
 | is_exactly_once              | Boolean | 否       | false                        | 是否启用精确一次语义,这将使用Xa事务。如果启用,则需要<br/>设置`xa_data_source_class_name`。                                                                                                              |
 | generate_sink_sql            | Boolean | 否       | false                        | 根据要写入的数据库表生成sql语句                                                                                                                                                                       |
-| xa_data_source_class_name    | String  | 否       | -                            | 数据库Driver的xa数据源类名,例如mysql是`com.mysql.cj.jdbc。MysqlXADataSource,和<br/>请参阅附录了解其他数据源                                                                     |
+| xa_data_source_class_name    | String  | 否       | -                            | 数据库 Driver 的 xa 数据源类名,例如 MySQL 是 `com.mysql.cj.jdbc.MysqlXADataSource`,<br/>其他数据源请参考对应驱动文档。                                                                     |
 | max_commit_attempts          | Int     | 否       | 3                            | 事务提交失败的重试次数                                                                                                                                                                                          |
-| transaction_timeout_sec      | Int     | 否       | -1                           | 事务打开后的超时,默认值为-1(永不超时)。请注意,设置超时可能会影响<br/>精确一次语义                                                                                            |
+| transaction_timeout_sec      | Int     | 否       | -1                           | 事务打开后的超时,默认值为 -1(永不超时)。请注意,设置超时可能会影响<br/>精确一次语义                                                                                            |
 | auto_commit                  | Boolean | 否       | true                         | 默认情况下启用自动事务提交                                                                                                                                                                                             |
-| field_ide                    | String  | 否       | -                            | 确定从源同步到 Sink 时是否需要转换字段`ORIGINAL表示不需要转换`大写`表示转换为大写`LOWERCASE表示转换为小写。     |
+| field_ide                    | String  | 否       | -                            | 确定从源同步到 Sink 时是否需要转换字段。`ORIGINAL` 表示不需要转换;`UPPERCASE` 表示转换为大写;`LOWERCASE` 表示转换为小写。     |
 | properties                   | Map     | 否       | -                            | 其他连接配置参数,当属性和URL具有相同的参数时,优先级由驱动程序的特定实现决定。例如,在MySQL中,属性优先于URL。 |
 | common-options               |         | 否       | -                            | Sink插件常用参数,请参考 [Sink Common Options](../common-options/sink-common-options.md) 详见                                                                                                                                    |
 | schema_save_mode             | Enum    | 否       | CREATE_SCHEMA_WHEN_NOT_EXIST | 在启动同步任务之前,对目标侧的现有表面结构选择不同的处理方案。                                                                                                      |
 | data_save_mode               | Enum    | 否       | APPEND_DATA                  | 在启动同步任务之前,对目标端的现有数据选择不同的处理方案。                                                                                                                 |
 | custom_sql                   | String  | 否       | -                            | 当data_save_mode选择CUSTOM_PROCESSING时,您应该填写CUSTOM_SQL参数。此参数通常填充可以执行的SQL。SQL将在同步任务之前执行。                                     |
-| enable_upsert                | Boolean | 否       | true                         | 通过primary_keys存在启用upstart,如果任务只有“插入”,将此参数设置为“false”可以加快数据导入                                                                                                                 |
+| enable_upsert                | Boolean | 否       | true                         | 通过 `primary_keys` 存在启用 upsert,如果任务只有 “插入”,将此参数设置为 “false” 可以加快数据导入                                                                                                                 |
 | multi_table_sink_replica     | Int     | 否       | 1                            | 多表写入时使用的 Sink Writer 副本数量。                                                                                                                 |
 
 ### 提示
diff --git a/docs/zh/connectors/source/GraphQL.md b/docs/zh/connectors/source/GraphQL.md
index 5d5dfb5257..805f3ee620 100644
--- a/docs/zh/connectors/source/GraphQL.md
+++ b/docs/zh/connectors/source/GraphQL.md
@@ -160,6 +160,96 @@ sink {
 }
 ```
 
+### 带鉴权头的 GraphQL 查询
+
+GraphQL 服务需要鉴权时,可以把 bearer token 等放在 `headers` 里。底层 HTTP 客户端
+支持的任何请求头都可以通过这个参数传递。
+
+```hocon
+env {
+  parallelism = 1
+  job.mode = "BATCH"
+}
+
+source {
+  GraphQL {
+    plugin_output = "graphql_auth"
+    url = "https://graphql.example.com/v1/graphql"
+    format = "json"
+    content_field = "$.data.source"
+    headers = {
+      Authorization = "Bearer ${secret}"
+      X-Tenant = "acme"
+    }
+    query = """
+      query MyQuery {
+        source {
+          id
+          val_bool
+        }
+      }
+    """
+    schema = {
+      fields {
+        id = "int"
+        val_bool = "boolean"
+      }
+    }
+  }
+}
+
+sink {
+  Console {
+    plugin_input = "graphql_auth"
+  }
+}
+```
+
+### 流式轮询查询
+
+对于只提供 HTTP 接口、但会持续发布新数据的服务,可以用流模式周期性地重复执行
+同一条查询。SeaTunnel 按 `poll_interval_millis` 发送请求,并把新行转发给下游算子。
+
+```hocon
+env {
+  parallelism = 1
+  job.mode = "STREAMING"
+  checkpoint.interval = 60000
+}
+
+source {
+  GraphQL {
+    plugin_output = "graphql_streaming"
+    url = "http://graphql:8080/v1/graphql"
+    format = "json"
+    content_field = "$.data.source"
+    poll_interval_millis = 10000
+    query = """
+      query MyQuery {
+        source {
+          id
+          val_bool
+          val_double
+        }
+      }
+    """
+    schema = {
+      fields {
+        id = "int"
+        val_bool = "boolean"
+        val_double = "double"
+      }
+    }
+  }
+}
+
+sink {
+  Console {
+    plugin_input = "graphql_streaming"
+  }
+}
+```
+
 ## 变更日志
 
 <ChangeLog />
diff --git a/docs/zh/connectors/source/Prometheus.md b/docs/zh/connectors/source/Prometheus.md
index a82009bb14..8d8511f728 100644
--- a/docs/zh/connectors/source/Prometheus.md
+++ b/docs/zh/connectors/source/Prometheus.md
@@ -155,6 +155,76 @@ source {
 }
 ```
 
+## 流式范围查询示例
+
+持续对 Prometheus 或 VictoriaMetrics 发起范围查询。Source 会按 `poll_interval_millis`
+周期性地重新执行同一个固定时间窗口的范围查询。`start` 和 `end` 会在作业启动时解析,
+因此时间窗口不会随着轮询推进。
+
+```hocon
+env {
+  parallelism = 1
+  job.mode = "STREAMING"
+  checkpoint.interval = 60000
+}
+
+source {
+  Prometheus {
+    plugin_output = "live_metrics"
+    url = "http://prometheus:9090"
+    query = "rate(node_cpu_seconds_total{mode!=\"idle\"}[1m])"
+    query_type = "Range"
+    start = "2026-08-10T00:00:00Z"
+    end = CURRENT_TIMESTAMP
+    step = "30s"
+    content_field = "$.data.result.*"
+    format = "json"
+    poll_interval_millis = 15000
+    retry = 3
+    retry_backoff_multiplier_ms = 200
+    retry_backoff_max_ms = 5000
+    schema = {
+      fields {
+        metric = "map<string, string>"
+        value = double
+        time = long
+      }
+    }
+  }
+}
+
+sink {
+  Console {}
+}
+```
+
+## 使用 Unix 时间戳的范围查询
+
+`start` 和 `end` 也支持填写以秒为单位的 Unix 时间戳。当需要从一个已知时间点回填一段固定窗口时,这种写法会更直接。
+
+```hocon
+source {
+  Prometheus {
+    plugin_output = "backfill"
+    url = "http://prometheus:9090"
+    query = "sum(up) by (job)"
+    query_type = "Range"
+    start = "1754851200"
+    end = "1754937600"
+    step = "60s"
+    content_field = "$.data.result.*"
+    format = "json"
+    schema = {
+      fields {
+        metric = "map<string, string>"
+        value = double
+        time = long
+      }
+    }
+  }
+}
+```
+
 ## 变更日志
 
 <ChangeLog />