feat: add openlit & openobserve & buildingai

This commit is contained in:
Sun-ZhenXing
2026-01-15 09:12:18 +08:00
parent b3c2708a53
commit 3efc2150fe
14 changed files with 1741 additions and 0 deletions

121
apps/openlit/.env.example Normal file
View File

@@ -0,0 +1,121 @@
# OpenLIT Configuration
# Copy this file to .env and modify as needed
# =============================================================================
# Version Configuration
# =============================================================================
# OpenLIT version (default: latest)
OPENLIT_VERSION=latest
# ClickHouse version
CLICKHOUSE_VERSION=24.4.1
# =============================================================================
# Global Configuration
# =============================================================================
# Global registry prefix for all images (optional)
# GLOBAL_REGISTRY=
# Time zone (default: UTC)
TZ=UTC
# =============================================================================
# Database Configuration
# =============================================================================
# ClickHouse database name
OPENLIT_DB_NAME=openlit
# ClickHouse username
OPENLIT_DB_USER=default
# ClickHouse password
OPENLIT_DB_PASSWORD=OPENLIT
# =============================================================================
# Port Configuration
# =============================================================================
# OpenLIT UI port on host (default: 3000)
OPENLIT_PORT_OVERRIDE=3000
# OpenLIT internal port (do not change unless necessary)
OPENLIT_INTERNAL_PORT=3000
# OTLP gRPC receiver port (default: 4317)
OPENLIT_OTLP_GRPC_PORT_OVERRIDE=4317
# OTLP HTTP receiver port (default: 4318)
OPENLIT_OTLP_HTTP_PORT_OVERRIDE=4318
# ClickHouse HTTP port (default: 8123)
CLICKHOUSE_HTTP_PORT_OVERRIDE=8123
# ClickHouse Native protocol port (default: 9000)
CLICKHOUSE_NATIVE_PORT_OVERRIDE=9000
# =============================================================================
# Resource Limits - OpenLIT
# =============================================================================
# CPU limit for OpenLIT
OPENLIT_CPU_LIMIT=1.0
# Memory limit for OpenLIT
OPENLIT_MEMORY_LIMIT=2G
# CPU reservation for OpenLIT
OPENLIT_CPU_RESERVATION=0.25
# Memory reservation for OpenLIT
OPENLIT_MEMORY_RESERVATION=512M
# =============================================================================
# Resource Limits - ClickHouse
# =============================================================================
# CPU limit for ClickHouse
CLICKHOUSE_CPU_LIMIT=2.0
# Memory limit for ClickHouse
CLICKHOUSE_MEMORY_LIMIT=4G
# CPU reservation for ClickHouse
CLICKHOUSE_CPU_RESERVATION=0.5
# Memory reservation for ClickHouse
CLICKHOUSE_MEMORY_RESERVATION=2G
# =============================================================================
# Application Configuration
# =============================================================================
# Enable telemetry
TELEMETRY_ENABLED=true
# =============================================================================
# OAuth Configuration (Optional)
# =============================================================================
# Google OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# GitHub OAuth
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# =============================================================================
# OpAMP Server Configuration
# =============================================================================
# Environment Mode: development, production, testing (default: production)
OPAMP_ENVIRONMENT=production
# Skip certificate verification (development only, default: false)
OPAMP_TLS_INSECURE_SKIP_VERIFY=false
# Require client certificates for mutual TLS (default: true)
OPAMP_TLS_REQUIRE_CLIENT_CERT=true
# TLS minimum version: 1.0, 1.1, 1.2, 1.3 (default: 1.2)
OPAMP_TLS_MIN_VERSION=1.2
# TLS maximum version: 1.0, 1.1, 1.2, 1.3 (default: 1.3)
OPAMP_TLS_MAX_VERSION=1.3
# Logging level: debug, info, warn, error (default: info)
OPAMP_LOG_LEVEL=info

221
apps/openlit/README.md Normal file
View File

@@ -0,0 +1,221 @@
# OpenLIT
OpenLIT is an open-source platform for AI engineering that provides OpenTelemetry-native observability, monitoring, and management tools for large language models (LLMs), GPUs, and vector databases.
## Features
- **📈 Analytics Dashboard**: Monitor your AI application's health and performance with detailed dashboards that track metrics, costs, and user interactions
- **🔌 OpenTelemetry-native Observability SDKs**: Vendor-neutral SDKs to send traces and metrics to your existing observability tools
- **💲 Cost Tracking**: Tailor cost estimations for specific models using custom pricing files for precise budgeting
- **🐛 Exceptions Monitoring**: Quickly spot and resolve issues by tracking common exceptions and errors
- **💭 Prompt Management**: Manage and version prompts using Prompt Hub for consistent and easy access across applications
- **🔑 API Keys and Secrets Management**: Securely handle your API keys and secrets centrally
- **🎮 Experiment with different LLMs**: Use OpenGround to explore, test and compare various LLMs side by side
- **🚀 Fleet Hub for OpAMP Management**: Centrally manage and monitor OpenTelemetry Collectors across your infrastructure using the OpAMP (Open Agent Management Protocol) with secure TLS communication
## Quick Start
1. Copy `.env.example` to `.env` and customize as needed:
```bash
cp .env.example .env
```
2. Start the services:
```bash
docker compose up -d
```
3. Access OpenLIT at `http://localhost:3000`
4. Login with default credentials:
- Email: `user@openlit.io`
- Password: `openlituser`
## Components
This deployment includes:
- **OpenLIT Platform**: Main application providing the UI and API (Port: 3000)
- **ClickHouse**: Database for storing telemetry data (Ports: 8123, 9000)
- **OTLP Receivers**:
- gRPC: Port 4317
- HTTP: Port 4318
## Integration with Your Applications
To integrate OpenLIT with your AI applications:
### Python SDK
```bash
pip install openlit
```
```python
import openlit
openlit.init(
otlp_endpoint="http://localhost:4318"
)
```
### TypeScript SDK
```bash
npm install openlit
```
```typescript
import Openlit from 'openlit';
Openlit.init({
otlpEndpoint: 'http://localhost:4318'
});
```
## Environment Variables
Key configuration options (see `.env.example` for all options):
| Variable | Description | Default |
| --------------------------------- | ----------------------------------- | ------------ |
| `OPENLIT_VERSION` | OpenLIT image version | `latest` |
| `CLICKHOUSE_VERSION` | ClickHouse version | `24.4.1` |
| `OPENLIT_PORT_OVERRIDE` | UI port on host | `3000` |
| `OPENLIT_OTLP_HTTP_PORT_OVERRIDE` | OTLP HTTP port | `4318` |
| `OPENLIT_OTLP_GRPC_PORT_OVERRIDE` | OTLP gRPC port | `4317` |
| `OPENLIT_DB_PASSWORD` | ClickHouse password | `OPENLIT` |
| `OPAMP_ENVIRONMENT` | OpAMP mode (development/production) | `production` |
## Resource Requirements
Default resource allocations:
- **OpenLIT**:
- Limits: 1 CPU, 2GB RAM
- Reservations: 0.25 CPU, 512MB RAM
- **ClickHouse**:
- Limits: 2 CPU, 4GB RAM
- Reservations: 0.5 CPU, 2GB RAM
Adjust these in `.env` file based on your workload.
## OAuth Configuration (Optional)
To enable OAuth authentication:
1. Configure Google OAuth:
```env
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
```
2. Configure GitHub OAuth:
```env
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret
```
## OpAMP Fleet Hub
OpenLIT includes an OpAMP server for centralized management of OpenTelemetry Collectors:
- Access Fleet Hub at: `http://localhost:3000/fleet-hub`
- OpAMP endpoint: `wss://localhost:4320/v1/opamp` (production mode)
- API endpoint: `http://localhost:8080`
For production deployments, ensure proper TLS configuration:
```env
OPAMP_ENVIRONMENT=production
OPAMP_TLS_INSECURE_SKIP_VERIFY=false
OPAMP_TLS_REQUIRE_CLIENT_CERT=true
```
## Supported Integrations
OpenLIT provides automatic instrumentation for 50+ LLM providers, vector databases, and frameworks including:
- **LLM Providers**: OpenAI, Anthropic, Cohere, Azure OpenAI, Google Vertex AI, Bedrock, and more
- **Vector Databases**: Pinecone, Weaviate, ChromaDB, Qdrant, Milvus, and more
- **Frameworks**: LangChain, LlamaIndex, Haystack, AutoGen, CrewAI, and more
## Health Checks
The OpenLIT service includes health checks to ensure proper startup. The service is considered healthy when:
- The web interface responds on the configured port
- Interval: 30 seconds
- Timeout: 10 seconds
- Start period: 60 seconds
## Data Persistence
Data is persisted in Docker volumes:
- `clickhouse_data`: ClickHouse database files
- `openlit_data`: OpenLIT application data including SQLite database
## Monitoring
Monitor your deployment:
```bash
# View logs
docker compose logs -f openlit
# Check service status
docker compose ps
# View resource usage
docker stats
```
## Security Notes
1. **Change default password**: Update `OPENLIT_DB_PASSWORD` in production
2. **TLS Configuration**: For production, use proper TLS certificates with OpAMP
3. **OAuth**: Consider enabling OAuth for enhanced security
4. **Network**: By default, services are exposed on all interfaces. Consider using a reverse proxy in production
## Troubleshooting
### Service won't start
- Check logs: `docker compose logs openlit`
- Verify ClickHouse is healthy: `docker compose ps`
- Ensure ports are not in use
### Cannot connect to OTLP endpoint
- Verify firewall settings
- Check port configuration in `.env`
- Ensure the endpoint URL is correct in your application
### High resource usage
- Adjust resource limits in `.env`
- Monitor with: `docker stats`
- Consider scaling ClickHouse resources for large workloads
## Documentation
- Official Documentation: <https://docs.openlit.io/>
- GitHub Repository: <https://github.com/openlit/openlit>
- Python SDK: <https://github.com/openlit/openlit/tree/main/sdk/python>
- TypeScript SDK: <https://github.com/openlit/openlit/tree/main/sdk/typescript>
## License
OpenLIT is available under the Apache-2.0 license.
## Support
- [Slack Community](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
- [Discord](https://discord.gg/CQnXwNT3)
- [GitHub Issues](https://github.com/openlit/openlit/issues)
- [X/Twitter](https://twitter.com/openlit_io)

221
apps/openlit/README.zh.md Normal file
View File

@@ -0,0 +1,221 @@
# OpenLIT
OpenLIT 是一个开源的 AI 工程平台为大型语言模型LLM、GPU 和向量数据库提供 OpenTelemetry 原生的可观测性、监控和管理工具。
## 功能特性
- **📈 分析仪表板**:通过详细的仪表板监控 AI 应用程序的健康状况和性能,跟踪指标、成本和用户交互
- **🔌 OpenTelemetry 原生可观测性 SDK**:供应商中立的 SDK可将跟踪和指标发送到现有的可观测性工具
- **💲 成本跟踪**:使用自定义定价文件为特定模型定制成本估算,实现精确预算
- **🐛 异常监控**:通过跟踪常见异常和错误快速发现并解决问题
- **💭 提示词管理**:使用 Prompt Hub 管理和版本化提示词,确保应用程序之间的一致性和便捷访问
- **🔑 API 密钥和密钥管理**:集中安全地处理 API 密钥和密钥
- **🎮 实验不同的 LLM**:使用 OpenGround 并排探索、测试和比较各种 LLM
- **🚀 OpAMP 管理的 Fleet Hub**:使用 OpAMP开放代理管理协议集中管理和监控整个基础设施中的 OpenTelemetry Collector并支持安全的 TLS 通信
## 快速开始
1. 复制 `.env.example``.env` 并根据需要自定义:
```bash
cp .env.example .env
```
2. 启动服务:
```bash
docker compose up -d
```
3. 访问 OpenLIT`http://localhost:3000`
4. 使用默认凭据登录:
- 邮箱:`user@openlit.io`
- 密码:`openlituser`
## 组件说明
此部署包含以下组件:
- **OpenLIT 平台**:提供 UI 和 API 的主应用程序端口3000
- **ClickHouse**存储遥测数据的数据库端口8123、9000
- **OTLP 接收器**
- gRPC端口 4317
- HTTP端口 4318
## 与应用程序集成
将 OpenLIT 集成到 AI 应用程序:
### Python SDK
```bash
pip install openlit
```
```python
import openlit
openlit.init(
otlp_endpoint="http://localhost:4318"
)
```
### TypeScript SDK
```bash
npm install openlit
```
```typescript
import Openlit from 'openlit';
Openlit.init({
otlpEndpoint: 'http://localhost:4318'
});
```
## 环境变量
关键配置选项(查看 `.env.example` 获取所有选项):
| 变量 | 说明 | 默认值 |
| --------------------------------- | ------------------------------------ | ------------ |
| `OPENLIT_VERSION` | OpenLIT 镜像版本 | `latest` |
| `CLICKHOUSE_VERSION` | ClickHouse 版本 | `24.4.1` |
| `OPENLIT_PORT_OVERRIDE` | 主机上的 UI 端口 | `3000` |
| `OPENLIT_OTLP_HTTP_PORT_OVERRIDE` | OTLP HTTP 端口 | `4318` |
| `OPENLIT_OTLP_GRPC_PORT_OVERRIDE` | OTLP gRPC 端口 | `4317` |
| `OPENLIT_DB_PASSWORD` | ClickHouse 密码 | `OPENLIT` |
| `OPAMP_ENVIRONMENT` | OpAMP 模式development/production | `production` |
## 资源需求
默认资源分配:
- **OpenLIT**
- 限制1 CPU、2GB 内存
- 预留0.25 CPU、512MB 内存
- **ClickHouse**
- 限制2 CPU、4GB 内存
- 预留0.5 CPU、2GB 内存
根据工作负载在 `.env` 文件中调整这些值。
## OAuth 配置(可选)
要启用 OAuth 身份验证:
1. 配置 Google OAuth
```env
GOOGLE_CLIENT_ID=your-client-id
GOOGLE_CLIENT_SECRET=your-client-secret
```
2. 配置 GitHub OAuth
```env
GITHUB_CLIENT_ID=your-client-id
GITHUB_CLIENT_SECRET=your-client-secret
```
## OpAMP Fleet Hub
OpenLIT 包含用于集中管理 OpenTelemetry Collector 的 OpAMP 服务器:
- Fleet Hub 访问地址:`http://localhost:3000/fleet-hub`
- OpAMP 端点:`wss://localhost:4320/v1/opamp`(生产模式)
- API 端点:`http://localhost:8080`
对于生产部署,请确保正确的 TLS 配置:
```env
OPAMP_ENVIRONMENT=production
OPAMP_TLS_INSECURE_SKIP_VERIFY=false
OPAMP_TLS_REQUIRE_CLIENT_CERT=true
```
## 支持的集成
OpenLIT 为 50 多种 LLM 提供商、向量数据库和框架提供自动仪表化,包括:
- **LLM 提供商**OpenAI、Anthropic、Cohere、Azure OpenAI、Google Vertex AI、Bedrock 等
- **向量数据库**Pinecone、Weaviate、ChromaDB、Qdrant、Milvus 等
- **框架**LangChain、LlamaIndex、Haystack、AutoGen、CrewAI 等
## 健康检查
OpenLIT 服务包含健康检查以确保正确启动。当满足以下条件时,服务被视为健康:
- Web 界面在配置的端口上响应
- 间隔30 秒
- 超时10 秒
- 启动期60 秒
## 数据持久化
数据持久化在 Docker 卷中:
- `clickhouse_data`ClickHouse 数据库文件
- `openlit_data`OpenLIT 应用程序数据,包括 SQLite 数据库
## 监控
监控部署:
```bash
# 查看日志
docker compose logs -f openlit
# 检查服务状态
docker compose ps
# 查看资源使用情况
docker stats
```
## 安全注意事项
1. **更改默认密码**:在生产环境中更新 `OPENLIT_DB_PASSWORD`
2. **TLS 配置**:对于生产环境,请在 OpAMP 中使用正确的 TLS 证书
3. **OAuth**:考虑启用 OAuth 以增强安全性
4. **网络**:默认情况下,服务在所有接口上公开。在生产环境中考虑使用反向代理
## 故障排除
### 服务无法启动
- 检查日志:`docker compose logs openlit`
- 验证 ClickHouse 是否健康:`docker compose ps`
- 确保端口未被占用
### 无法连接到 OTLP 端点
- 验证防火墙设置
- 检查 `.env` 中的端口配置
- 确保应用程序中的端点 URL 正确
### 资源使用率高
- 在 `.env` 中调整资源限制
- 使用以下命令监控:`docker stats`
- 考虑为大型工作负载扩展 ClickHouse 资源
## 文档
- 官方文档:<https://docs.openlit.io/>
- GitHub 仓库:<https://github.com/openlit/openlit>
- Python SDK<https://github.com/openlit/openlit/tree/main/sdk/python>
- TypeScript SDK<https://github.com/openlit/openlit/tree/main/sdk/typescript>
## 许可证
OpenLIT 采用 Apache-2.0 许可证。
## 支持
- [Slack 社区](https://join.slack.com/t/openlit/shared_invite/zt-2etnfttwg-TjP_7BZXfYg84oAukY8QRQ)
- [Discord](https://discord.gg/CQnXwNT3)
- [GitHub Issues](https://github.com/openlit/openlit/issues)
- [X/Twitter](https://twitter.com/openlit_io)

View File

@@ -0,0 +1,97 @@
# OpenLIT - AI Engineering Observability Platform
# OpenLIT provides OpenTelemetry-native LLM Observability, GPU Monitoring,
# Guardrails, Evaluations, Prompt Management, Vault, and Playground.
# Repository: https://github.com/openlit/openlit
x-defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
services:
clickhouse:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}clickhouse/clickhouse-server:${CLICKHOUSE_VERSION:-24.4.1}
environment:
- TZ=${TZ:-UTC}
- CLICKHOUSE_PASSWORD=${OPENLIT_DB_PASSWORD:-OPENLIT}
- CLICKHOUSE_USER=${OPENLIT_DB_USER:-default}
- CLICKHOUSE_DATABASE=${OPENLIT_DB_NAME:-openlit}
- CLICKHOUSE_ALWAYS_RUN_INITDB_SCRIPTS=true
volumes:
- clickhouse_data:/var/lib/clickhouse
ports:
- "${CLICKHOUSE_HTTP_PORT_OVERRIDE:-8123}:8123"
- "${CLICKHOUSE_NATIVE_PORT_OVERRIDE:-9000}:9000"
healthcheck:
test: ["CMD-SHELL", "clickhouse-client --user=$${CLICKHOUSE_USER} --password=$${CLICKHOUSE_PASSWORD} --query='SELECT 1' || exit 1"]
interval: 5s
timeout: 3s
retries: 10
start_period: 100s
deploy:
resources:
limits:
cpus: ${CLICKHOUSE_CPU_LIMIT:-2.0}
memory: ${CLICKHOUSE_MEMORY_LIMIT:-4G}
reservations:
cpus: ${CLICKHOUSE_CPU_RESERVATION:-0.5}
memory: ${CLICKHOUSE_MEMORY_RESERVATION:-2G}
openlit:
<<: *defaults
image: ${GLOBAL_REGISTRY:-}ghcr.io/openlit/openlit:${OPENLIT_VERSION:-latest}
environment:
- TZ=${TZ:-UTC}
- TELEMETRY_ENABLED=${TELEMETRY_ENABLED:-true}
- INIT_DB_HOST=clickhouse
- INIT_DB_PORT=8123
- INIT_DB_DATABASE=${OPENLIT_DB_NAME:-openlit}
- INIT_DB_USERNAME=${OPENLIT_DB_USER:-default}
- INIT_DB_PASSWORD=${OPENLIT_DB_PASSWORD:-OPENLIT}
- SQLITE_DATABASE_URL=file:/app/client/data/data.db
- PORT=${OPENLIT_INTERNAL_PORT:-3000}
- DOCKER_PORT=${OPENLIT_INTERNAL_PORT:-3000}
# OAuth Configuration (Optional)
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID:-}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET:-}
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID:-}
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET:-}
# OpAMP Server Configuration
- OPAMP_ENVIRONMENT=${OPAMP_ENVIRONMENT:-production}
- OPAMP_CERTS_DIR=/app/opamp/certs
- OPAMP_TLS_INSECURE_SKIP_VERIFY=${OPAMP_TLS_INSECURE_SKIP_VERIFY:-false}
- OPAMP_TLS_REQUIRE_CLIENT_CERT=${OPAMP_TLS_REQUIRE_CLIENT_CERT:-true}
- OPAMP_TLS_MIN_VERSION=${OPAMP_TLS_MIN_VERSION:-1.2}
- OPAMP_TLS_MAX_VERSION=${OPAMP_TLS_MAX_VERSION:-1.3}
- OPAMP_LOG_LEVEL=${OPAMP_LOG_LEVEL:-info}
ports:
- "${OPENLIT_PORT_OVERRIDE:-3000}:${OPENLIT_INTERNAL_PORT:-3000}"
- "${OPENLIT_OTLP_GRPC_PORT_OVERRIDE:-4317}:4317"
- "${OPENLIT_OTLP_HTTP_PORT_OVERRIDE:-4318}:4318"
depends_on:
clickhouse:
condition: service_healthy
volumes:
- openlit_data:/app/client/data
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:${OPENLIT_INTERNAL_PORT:-3000}/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
deploy:
resources:
limits:
cpus: ${OPENLIT_CPU_LIMIT:-1.0}
memory: ${OPENLIT_MEMORY_LIMIT:-2G}
reservations:
cpus: ${OPENLIT_CPU_RESERVATION:-0.25}
memory: ${OPENLIT_MEMORY_RESERVATION:-512M}
volumes:
clickhouse_data:
openlit_data: