> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 对 ClickHouse 运行支持查询

此 Helm 仓库包含用于生成 LangSmith UI 当前不直接支持的输出的查询（例如，从 ClickHouse 获取查询异常日志）。

此命令接受一个包含嵌入式名称和密码的 ClickHouse 连接字符串（可以从调用密钥管理器传入），并从输入文件执行查询。在下面的示例中，我们使用 `support_queries/clickhouse` 目录中的 `ch_get_query_exceptions.sql` 输入文件。

### 前提条件

确保您已准备好以下工具/项目。

1. kubectl

   * [https://kubernetes.io/docs/tasks/tools/](https://kubernetes.io/docs/tasks/tools/)

2. ClickHouse 数据库凭据

   * 主机
   * 端口
   * 用户名
     * 如果使用捆绑版本，则为 `default`
   * 密码
     * 如果使用捆绑版本，则为 `password`
   * 数据库名称
     * 如果使用捆绑版本，则为 `default`

3. 从您将运行迁移脚本的机器到 ClickHouse 数据库的连接。

   * 如果您使用捆绑版本，可能需要将 ClickHouse 服务端口转发到您的本地机器。
   * 运行 `kubectl port-forward svc/langsmith-clickhouse 8123:8123` 将 ClickHouse 服务端口转发到您的本地机器。

4. 运行支持查询的脚本

   * 下载 [ClickHouse 支持查询脚本](https://github.com/langchain-ai/helm/blob/main/charts/langsmith/scripts/run_support_query_ch.sh)

### 运行查询脚本

运行以下命令以执行所需的查询：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
sh run_support_query_ch.sh <clickhouse_url> --input path/to/query.sql
```

例如，如果您使用的是带有端口转发的捆绑版本，命令可能如下所示：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
sh run_support_query_ch.sh "clickhouse://default:password@localhost:8123/default" --input support_queries/clickhouse/ch_get_query_exceptions.sql
```

这将输出过去 7 天内 ClickHouse 中所有抛出异常的查询的查询日志。要将此内容提取到文件中，请添加标志 `--output path/to/file.csv`

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/langsmith/script-running-ch-support-queries.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
