Data & Analytics · Web & Product Analytics
Trench
Kafka and ClickHouse infrastructure for real-time event analytics
Trench is MIT-licensed, open-source event tracking infrastructure for teams building product analytics, observability, audit logs, or related data systems. It combines Kafka, ClickHouse, and a Node.js application in a production Docker image, with self-hosting and a managed Trench Cloud option.
Key facts
- License
- MIT
- Main language
- TypeScript, JavaScript
- Maintainer
- Frigade
- First released
- 2024
- Latest release
- trench-js@0.0.17, December 4, 2024
- GitHub stars
- 1,645, October 2026
- Hosted option
- Trench Cloud
What Trench is
Trench is an event tracking system built and maintained by Frigade, which created it for its real-time tracking pipeline. The repository was created on September 30, 2024, and the GitHub view lists 1,645 stars, 63 forks, and 174 commits. Named contributors include christianmat, brownrout, and tuminzee, with christianmat listed at 132 contributions. The project describes use cases including product analytics, LLM retrieval-augmented generation systems, observability platforms, and other analytics products. Its README says Trench is no-cookie, GDPR compliant, and PECR compliant, with controls for accessing, rectifying, and deleting user data. Frigade backs the project and offers both self-hosted software and Trench Cloud.
How it works
Trench accepts Segment-compatible Track, Group, and Identify events through an authenticated HTTP interface. A typical deployment starts the server with Docker Compose, sends event batches to the events endpoint, retrieves filtered records through REST, and submits SQL through the queries endpoint for analysis. Kafka carries the event stream, while ClickHouse stores and serves analytical data. Webhooks send data to other destinations, and the website describes throttled outbound delivery. The README includes examples for posting a Track event, filtering by event name, and running a count query. Trench concentrates on ingestion and query infrastructure, while a dashboard can be assembled separately with tools such as Grafana. This workflow suits teams that want control over event schemas, storage, and presentation.
Architecture and recent releases
The application is primarily written in TypeScript and JavaScript, with CSS, Shell, MDX, and Dockerfile files also present. Kafka and ClickHouse form the central data path, and the project distributes a production Docker image alongside Docker Compose development files. Kafka connections support SASL mechanisms plain, SCRAM-SHA-256, and SCRAM-SHA-512, plus SSL and mutual TLS settings through environment variables. ClickHouse Kafka authentication is configured in server files. The displayed package releases include trench-js@0.0.17 and analytics-plugin-trench@0.0.9, both dated December 4, 2024. Repository activity includes an October 13, 2025 change adding Kafka SASL and SSL support with ClickHouse integration, followed by an April 6, 2026 workspace authorization fix.
License and pricing
Trench uses the MIT License, which permits commercial use, modification, distribution, sublicensing, and sale when the copyright and permission notices remain with copies or substantial portions. The repository does not describe an open-core split or a separate source-available restriction. Trench Cloud is a managed serverless option with autoscaling and a stated 99.99 percent SLA. The website lists enterprise features including volume-based pricing, dedicated infrastructure, a dedicated support engineer, 24/7 phone and email support, on-premises deployment, SAML 2.0 SSO, and third-party integrations. The project does not publish a Cloud price on the referenced website, so commercial terms depend on the selected hosted or enterprise arrangement.
Limitations and how it compares
Kafka and ClickHouse give Trench a clear event pipeline, but operating both systems requires more infrastructure work than a hosted analytics product. The project recommends at least 4 GB of RAM and four CPU cores for production, while storage sizing, backup procedures, upgrade automation, and a broader capacity model are not described. PostHog offers a broader open-source product analytics application, Matomo provides a complete web analytics product, and Segment supplies proprietary collection and routing services. Trench is the better choice for engineering teams that want MIT-licensed ingestion infrastructure, direct SQL access, and control of deployment. Teams that prioritize ready-made reports, behavioral analysis, or managed operations should compare PostHog, Matomo, and Segment first.
Main features
- Segment-compatible events. Accepts Track, Group, and Identify event types through an interface aligned with the Segment specification.
- Kafka event pipeline. Processes event streams with Apache Kafka and supports SASL, SSL, and mutual TLS connection settings.
- ClickHouse queries. Stores analytics data in ClickHouse and exposes real-time querying through REST endpoints and raw SQL requests.
- Production Docker image. Packages the application as a production Docker image, with Docker Compose instructions for local and self-hosted deployments.
- Webhook destinations. Sends event data to other destinations through webhooks, with throttled outbound delivery described on the website.
- Privacy controls. Describes no-cookie tracking and user controls for accessing, rectifying, or deleting stored data.
Self-hosting Trench
Self-hosting requires Docker and Docker Compose. The quickstart clones the repository, enters the application directory, copies the example environment file, and starts development Compose files. That setup includes local Kafka and ClickHouse instances and exposes the server on port 4000. The README recommends at least 4 GB of RAM and four CPU cores for production. External Kafka clusters can use SASL, SSL, custom certificate authorities, client certificates, and private keys through environment variables. ClickHouse authentication is configured separately in server configuration files. The project does not describe Helm charts, binary packages, automated upgrades, minimum storage, or backup procedures.
Strengths
- MIT licensing permits commercial use, modification, and redistribution.
- Kafka and ClickHouse provide a clear high-volume ingestion and query architecture.
- The API supports Segment-style Track, Group, and Identify events.
- A managed Cloud option is available alongside self-hosting.
Drawbacks
- Running Kafka and ClickHouse adds operational work compared with hosted analytics services.
- Production guidance specifies compute requirements but not storage or backup requirements.
- The latest displayed package release is trench-js@0.0.17 from December 4, 2024.
What teams replace with it
Teams usually evaluate Trench when they want to move off Segment, Mixpanel, Amplitude.
For side-by-side commercial comparisons, browse our alternatives hub.
Frequently asked questions
Is Trench free to use?
The self-hosted Trench code is available under the MIT License, and the website describes the open-source edition as having no usage limits. Trench Cloud is a separate managed service. The website describes Cloud and enterprise capabilities, but it does not publish a current Cloud price. Hosted costs depend on the selected arrangement.
Can companies use Trench commercially?
Yes. Trench is distributed under the MIT License, which permits use, copying, modification, distribution, sublicensing, and sale when the copyright and permission notice remain with copies or substantial portions. The repository does not describe a source-available restriction or SaaS limitation. Commercial deployments still need appropriate privacy, security, and retention controls.
How do you self-host Trench, and what hardware does it need?
The development setup includes Kafka and ClickHouse and serves the application on port 4000. The README recommends at least 4 GB of RAM and four CPU cores for production. It does not publish a minimum storage requirement.
How does Trench compare with PostHog?
Trench concentrates on event ingestion and analytical infrastructure built around Kafka and ClickHouse, exposing REST and SQL access. PostHog is a broader product analytics application with more built-in product-facing features. Trench suits teams that want to assemble their own analytics experience or control the data path. PostHog is a stronger starting point for teams seeking an integrated interface.
Does Trench support privacy and secure Kafka connections?
The README describes Trench as no-cookie and compliant with GDPR and PECR, with controls to access, rectify, or delete user data. Kafka connections can use SSL, mutual TLS, and SASL mechanisms including plain, SCRAM-SHA-256, and SCRAM-SHA-512. Those capabilities do not replace deployment-specific access control, retention, encryption, or compliance work.
Similar projects to compare
- PostHogMIT (except separately licensed enterprise code)PostHog is a developer-focused platform for product analytics, session replay, feature flags, experiments, error tracking, logs, AI observability, and data operations. The main repository uses the MIT Expat license outside the separately licensed ee directory. PostHog Cloud offers a permanent monthly free tier, while a Docker-based hobby deployment supports teams that want to run the open-source product themselves.
- MatomoGPL-3.0-or-laterMatomo is a GPL-3.0-or-later web analytics platform for organisations that need to collect, inspect, and retain website data on infrastructure they control. The free on-premise edition supports commercial use under the license terms, while Matomo Cloud provides hosted service from €29 per month with maintenance, automatic updates, security monitoring, and daily backups.
- CountlyAGPL-3.0 with modified Section 7 for Countly Lite; commercial license availableCountly is a self-hosted product analytics and customer engagement server for mobile, web, desktop, and connected-device applications. Countly Lite uses AGPL-3.0 with modified Section 7 for internal use and an organization’s own applications. Customer-facing deployments require commercial licensing. Countly Flex offers managed private-cloud hosting from $175 per month, with Enterprise plans available at custom pricing.
- AptabaseAGPL-3.0-only server; MIT SDKsAptabase is an open-source analytics platform for mobile, desktop and web applications. Its SDKs send selected events to a TypeScript service with dashboards, live views, session timelines and CSV export. The server is AGPLv3, SDKs are MIT, and deployments can use Docker Compose or cloud plans priced by monthly event volume.
- BetterlyticsAGPL-3.0Betterlytics combines cookieless web analytics, session replay, client-error tracking, Core Web Vitals, uptime checks and status pages in one dashboard. It is AGPL-3.0 licensed and offered through EU-hosted cloud software or Docker self-hosting. Cloud includes a free tier and paid monthly plans; self-hosting shifts infrastructure, maintenance and operational responsibility to the operator.
- DatabuddyAGPL-3.0Databuddy is an open-source product analytics platform for startups, combining cookieless visitor tracking, events, funnels, goals, AI analysis, feature flags, short links, and uptime monitoring. It uses AGPL-3.0, with MIT exceptions for two packages. A managed hosted service offers a free tier and paid plans from $9.99 per month, while teams can deploy it themselves with Docker Compose.