自托管 LangSmith 实例以日志、指标和追踪的形式生成遥测数据。本节将向您展示如何访问这些数据并将其导出到可观测性收集器或后端。
本节假设您已经设置了监控基础设施,或者您将设置此基础设施并希望了解如何配置 LangSmith 以从中收集数据。
基础设施包括:
- * 收集器,例如 OpenTelemetry, FluentBit or Prometheus.
- * 可观测性后端,例如 Datadog 或 Grafana ecosystem.
日志
参考设置,请参阅 OTel 收集器示例.
作为 LangSmith 自托管部署一部分的所有服务会将日志写入其节点的文件系统并输出到 stdout。为了访问这些日志,您需要设置收集器以从文件系统或 stdout 读取。大多数流行的收集器都支持从文件系统读取日志。
- * **OpenTelemetry**: 文件日志接收器
- * **FluentBit**: Tail 输入
- * **Datadog**: Kubernetes 日志收集
指标
参考设置,请参阅 OTel 收集器示例.
LangSmith 服务
以下 LangSmith 服务以 Prometheus 指标格式在端点处暴露指标。前端目前不暴露指标。
- * **后端**:
http://<langsmith_release_name>-backend.<namespace>.svc.cluster.local:1984/metrics - * **平台后端**:
http://<langsmith_release_name>-platform-backend.<namespace>.svc.cluster.local:1986/metrics - * **Playground**:
http://<langsmith_release_name>-playground.<namespace>.svc.cluster.local:1988/metrics - * **(仅限 LangSmith 控制平面)主机后端**:
http://<langsmith_release_name>-host-backend.<namespace>.svc.cluster.local:1985/metrics
您可以使用 Prometheus or OpenTelemetry 收集器来抓取端点,并将指标导出到您选择的后端。
前端 Nginx
前端服务在以下端点暴露其 Nginx 指标: langsmith-frontend.langsmith.svc.cluster.local:80/nginx_status。您可以自行抓取这些指标,或使用 Prometheus Nginx 导出器.
Postgres + Redis
If you are using in-cluster Postgres/Redis instances, you can use a Prometheus exporter to expose metrics from your instance. You can deploy a Postgres 导出器 and/or Redis 导出器.
Clickhouse
集群内 Clickhouse 配置为无需导出器即可暴露指标。您可以使用收集器从以下位置抓取指标 http://<langsmith_release_name>-clickhouse.<namespace>.svc.cluster.local:9363/metrics
追踪
参考设置,请参阅 OTel 收集器示例.
LangSmith 后端、平台后端、Playground 和 LangSmith Queue 部署已添加检测功能以发送 Otel 跟踪。跟踪默认关闭,您可以通过在您的配置中添加以下内容来为所有 LangSmith 服务启用跟踪 langsmith_config.yaml (或等效)文件中:
config:
tracing:
enabled: true
endpoint: "<your_collector_endpoint>"
useTls: true # / false
env: "ls_self_hosted" # This value will be set as an "env" attribute in your spans
exporter: "http" # must be either http or grpc