@super-ding/dsh-influxdb:在 DSH 里用 Flux 查 InfluxDB 2.x

前言

在 DeepSeek Harness(DSH)里做运维或观测类智能体时,经常需要查时序库:看 bucket、摸清 measurement 与 tag,再写 Flux 拉一段时间序列。若每次手写 curl 或把 token 塞进临时脚本,会话上下文容易爆,也不利于在面板里反复试查询。

@super-ding/dsh-influxdb 是面向 InfluxDB 2.x(Flux + token)的 DSH bundle:安装后 Agent 可直接调用原生工具执行查询、读 schema、管理连接;侧边栏提供 Flux 编辑器与连接管理。维护者为 super-ding,在 SkillHub 插件目录 归类为「联网工具」。InfluxDB 1.8 与 3.x 的接口与鉴权不同,不在本插件范围内。

这是什么

一句话:DeepSeek Harness 的 InfluxDB 2.x 插件——6 个智能体工具加一个侧边面板,可执行 Flux 查询、查看 schema 与 bucket、管理连接、在开启写权限后写入 line protocol。

默认形态是 DSH 原生插件工具,不是 MCP 服务器。装上 bundle 后,会话里可直接使用 influx_query、influx_schema 等工具名,无需配置 MCP。包内另有可选的 stdio MCP 服务器,供其他 MCP 客户端复用同一套能力。

核心能力

Agent 工具

工具 作用
influx_connections 列出连接(url / org / bucket / token 来源),ping: true 时可测 /health
influx_query 执行 Flux,返回 JSON 表格(列名 + 行数组),带行数上限与 truncated 标记
influx_schema 读 schema:buckets / measurements / fields / tags / tagValues
influx_buckets 列 bucket 及保留策略
influx_write 写 line protocol(默认关闭,需 allowWrite: true)
influx_flux Flux 编写辅助:validate 服务端校验、explain 管线解释、template 模板、params 模板清单

侧边面板

侧栏 InfluxDB 图标打开主面板:

  • 查询:连接选择、Flux 编辑器(Tab 缩进、Ctrl/Cmd+Enter 运行)、模板插入、服务端校验、结果表格。
  • 连接:新增 / 编辑 / 删除 / 设默认;tokenEnv 优先于明文 token;allowWrite 开关;保存后立即生效。

面板不做图表可视化,只展示表格;图表需求可将结果交给其他工具处理。

安装与配置

安装

从 npm 安装(推荐):

dsh plugin --profile desktop add @super-ding/dsh-influxdb

从 GitHub 安装(未发 npm 时的等价方式):

dsh plugin --profile desktop add github:super-ding/dsh-influxdb

安装 bundle 时会在 profile 的 cordis.patch.yml 自动插入默认插件行;也可按下面结构手改。

配置示例

插件行写在 profile 的 cordis.patch.yml:

- id: dsh-influxdb
  name: "@super-ding/dsh-influxdb"
  config:
    allowWrite: false        # 是否允许 influx_write 与面板写入
    timeoutMs: 30000         # 单次请求超时
    maxRows: 200             # 默认返回行数上限(1-2000)
    connections:
      - id: prod             # 连接 id,工具里用 connection 参数指定
        label: 生产 InfluxDB
        url: http://127.0.0.1:8086
        org: my-org
        bucket: metrics      # 默认 bucket,查询/schema/写入的缺省值
        tokenEnv: INFLUX_TOKEN   # 推荐:token 只放环境变量
        # token: "xxxx"      # 也可直接写,但不推荐
        default: true        # 工具的默认连接
      - id: staging
        url: http://10.0.0.12:8086
        org: my-org
        bucket: metrics_dev
        token: "staging-token"

token 也支持 env:INFLUX_TOKEN 或 ${INFLUX_TOKEN};tokenEnv 与 token 同时存在时,环境变量优先。面板里保存连接会通过 configEditor 写回同一行 config,与手改 YAML 等价。

建议为 token 配置最小权限,只读场景不要授予 write:

influx auth create --org my-org --read-bucket <id> [--write-bucket <id>]

即使插件里打开了 allowWrite,InfluxDB 仍会拒绝无写权限的 token。

典型用法

  1. 在 connections 里配好 url、org、bucket,token 优先走 tokenEnv。
  2. 在会话中让 Agent 调用 influx_connections(可选 ping: true)确认连通性。
  3. 用 influx_schema 摸清 measurement、field、tag,再用 influx_query 执行 Flux;结果受 maxRows 限制,超出部分会带 truncated。
  4. 需要起草或校验 Flux 时,使用 influx_flux 的 validate、explain、template 等能力。
  5. 必须在配置里设 allowWrite: true 后,才可通过 influx_write 或面板写入 line protocol。

侧边栏适合人工迭代:选连接、在编辑器里写 Flux、Ctrl/Cmd+Enter 运行,与服务端校验配合使用。

可选:以 MCP 服务器方式使用

若其他 MCP 客户端也需要同一套 InfluxDB 操作,可使用包内零依赖的 mcp-server.mjs(stdio)。步骤概要:

  1. 准备配置文件(可参考 mcp-config.example.json),结构与插件行 config 相同。
  2. 在 profile 的 cordis.patch.yml 增加 MCP 客户端,例如:
- id: influxdb-mcp
  name: "@deepseek-ai/dsh-mcp-client"
  config:
    serverName: influxdb
    transport: stdio
    command: node
    args:
      - "D:/path/to/dsh-influxdb/mcp-server.mjs"
      - "--config"
      - "D:/path/to/dsh-influxdb/mcp-config.json"
    env:
      INFLUX_TOKEN: !!js process.env.INFLUX_TOKEN
  1. 重载后工具名形如 mcp__influxdb__influx_query。

注意:stdio MCP 是独立进程,读 --config 指向的文件,不会自动继承面板里保存的连接,两处需分别配置。

安全边界与已知限制

  • 写能力默认关闭;关闭时 influx_write 返回 WRITE_DISABLED,不会发请求。
  • 面板 RPC POST /influxdb/rpc 只接受 loopback Origin,非本机来源返回 403。
  • 查询按 maxRows 截断并标注 truncated;单单元格最长 4000 字符。插件不在日志或工具结果中暴露完整 token;influx_connections 仅返回尾号与来源。
  • 仅支持 2.x 的 /api/v2/*;不支持 InfluxDB Cloud 目录级多 org 切换——一个连接对应一个 org,跨 org 用多个连接。

插件在 当前 DSH 进程权限 下访问你配置的 URL 与 token。安装前建议查看 GitHub 仓库 源码与 MIT 许可证,确认符合你的环境策略。DSH 生态理念是「一切皆插件」;SkillHub 为社区目录,与 DeepSeek / 幻方无官方从属关系。

结尾

@super-ding/dsh-influxdb 把 InfluxDB 2.x 的 Flux 查询、schema 探查、连接管理与可选写入收进 DSH 原生工具与侧边面板,减少在会话里拼 HTTP 的重复劳动。目录页:https://www.skillhub.cn/plugins/super-ding/dsh-influxdb;源码与文档:https://github.com/super-ding/dsh-influxdb。

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜