trench
Trench — 開放原始碼分析基礎架構。一個基於 ClickHouse、Kafka 和 Node.js 打造的單一生產級 Docker 映像,用於追蹤事件。輕鬆建立
trench 是什麼?
Trench — 開放原始碼分析基礎架構。一個基於 ClickHouse、Kafka 和 Node.js 打造的單一生產級 Docker 映像,用於追蹤事件。輕鬆建立產品分析儀表板、LLM RAG、可觀測性平台或任何其他分析產品。
trench 概覽
Trench — 開源分析基礎設施(Open-Source Analytics Infrastructure) Trench 是一套以 Apache Kafka 與 ClickHouse 為基礎的事件追蹤系統,可處理大量事件並提供即時分析。Trench 不依賴 cookie,符合 GDPR 與 PECR 規範,使用者可完全掌控資料的存取、修正或刪除。 ## 功能特色 - 相容於 Segment API(Track、Group、Identify) - 單一 production-ready Docker image,快速部署 - 單一節點每秒可處理數千個事件 - 即時查詢資料 - 透過 webhook 將資料連接到其他目的地 - 開放原始碼,MIT 授權
快速開始
Trench 提供兩種部署方式: 1. Trench Self-Hosted:開放原始碼版本,可在自己的基礎設施上部署與管理 Trench。 2. Trench Cloud:全託管無伺服器方案,具備零維運、自動擴展與 99.99% SLA。 ### 1. Trench Self-Hosted 💻 請依照下方與快速入門指南中的自架說明開始使用 Trench Self-Hosted。 若有疑問或需要協助,可加入 Slack 群組尋求支援。
快速開始
- 部署 Trench Dev Server:Trench 唯一的先決條件是安裝了 Docker 與 Docker Compose 的系統。若要在生產環境執行,建議至少 4GB RAM 與 4 個 CPU 核心。 安裝 Docker 後,執行以下指令啟動本機開發伺服器:
sh git clone https://github.com/frigadehq/trench.git cd trench/apps/trench cp .env.example .env docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build --force-recreate --renew-anon-volumesThe above command will start the Trench server that includes a local ClickHouse and Kafka instance onhttp://localhost:4000. You can open this URL in your browser and you should see the messageTrench server is running. You shouldupdate the.envfile to change any of the configuration options. 2. Send a sample event: You can find and update the default public and private API key in the.envfile. Using your public API key, you can send a sample event to Trench as such:sh curl -i -X POST ...3. Querying events: You can query events using the/eventsendpoint (see API reference for more details). You can also query events directly from your local Trench server. For example, to query events of typeConnectedAccount, you can use the following URL: ... 4. Execute raw SQL queries: Use the queries endpoint to analyze your data. Example: ... ### Kafka authentication Trench supports connecting to Kafka clusters that require SASL and/or SSL. Configure via the following environment variables (all optional):
KAFKA_SSL_ENABLED: Enable SSL/TLS when connecting to brokers. Values:true/false(default:false).KAFKA_SSL_REJECT_UNAUTHORIZED: Whether to verify broker certificates. Values:true/false(default:true). Set tofalsewhen using self-signed certs in development.KAFKA_SSL_CA: CA certificate contents (PEM). Use when brokers use self-signed certs in development.KAFKA_SSL_CERT: Client certificate contents (PEM). Required when using mTLS.KAFKA_SSL_KEY: Client private key contents (PEM). Required when using mTLS.KAFKA_SASL_ENABLED: Enable SASL authentication. Values:true/false(default:false).KAFKA_SASL_USERNAME: Username for SASL authentication.KAFKA_SASL_PASSWORD: Password for SASL authentication.KAFKA_SASL_MECHANISM: SASL mechanism. Values:PLAIN,SCRAM-SHA-256,SCRAM-SHA-512(default:PLAIN).KAFKA_SASL_SECURITY_PROTOCOL: Security protocol. Values:SASL_PLAINTEXTorSASL_SSL(default:SASL_PLAINTEXT).
內容整理自該專案公開的 README 與儲存庫資訊。