Tianji
Replace Google Analytics, UptimeKuma, and Prometheus with one self-hosted platform that tracks websites, monitors uptime, and reports server health.
Tianji is an open-source, all-in-one observability platform that unifies website analytics, uptime monitoring, server status tracking, telemetry collection, surveys, and AI gateway management into a single self-hosted application. It eliminates the operational burden of running separate tools like Google Analytics, Umami, UptimeKuma, and Prometheus for developers and small teams with lightweight monitoring needs.
Built on a TypeScript monorepo with Express, tRPC, and React 18, Tianji is designed for Docker-first deployment with one-click options for Render, Sealos, Hostinger, and ClawCloud. Its cookieless website analytics tracker is GDPR and CCPA compliant, while its Go-based server reporter delivers real-time CPU, memory, and disk metrics via UDP without requiring Prometheus exporters.
Beyond basic observability, Tianji includes an AI gateway that proxies requests to multiple LLM providers—OpenAI, Anthropic, DeepSeek, and OpenRouter—with per-request cost tracking, custom pricing overrides, and quota alerting. Serverless-style function workers with distributed locking and Monaco-based revision diffing enable programmable automation directly within the platform.
An optional ClickHouse integration handles high-throughput analytics workloads for teams that outgrow PostgreSQL query performance, while a native MCP server exposes Tianji functionality to AI coding assistants. The result is a pragmatic platform that lets a single operator replace an entire monitoring stack without sacrificing observability depth.
What You Get
- Cookieless Website Analytics - Tracks page views, unique visitors, referrers, UTM parameters, and traffic sources without cookies, fully GDPR and CCPA compliant with a lightweight JavaScript tracker.
- Uptime Monitoring - Monitors endpoints with passive result reception, configurable check intervals, and real-time status updates with multi-channel notification support.
- Server Status Reporting - A lightweight Go binary (the reporter) ships CPU, memory, disk, and network metrics via UDP to the Tianji server without requiring Prometheus exporters.
- Docker Container Monitoring - Tracks container health and resource usage from Docker environments directly alongside server metrics.
- Public Status Pages - Generates branded public-facing status pages with real-time uptime displays and incident communication for end users and customers.
- AI Gateway with Cost Tracking - Proxies LLM requests to OpenAI, Anthropic, DeepSeek, and OpenRouter with per-request token and cost tracking, custom model pricing overrides, and quota alerts.
- Function Workers - Executes serverless-style JavaScript functions on a cron schedule with isolated-vm sandboxing, distributed locking for cluster safety, and Monaco-based revision history diffing.
- Telemetry Collection - Embeds a telemetry badge in open-source projects to collect deployment statistics anonymously without invasive user tracking.
- Surveys and Feeds - Embeds user feedback surveys into web properties and publishes structured event feeds for status updates and incident notifications.
- MCP Server - Exposes Tianji survey data and workspace functionality to AI coding assistants via the Model Context Protocol.
- OpenAPI Access - Full RESTful API generated from tRPC router definitions with Swagger UI and Stoplight Elements documentation for custom integrations.
- Lighthouse Performance Reports - Runs Puppeteer-driven Lighthouse audits against target URLs and stores results directly in the analytics dashboard.
Common Use Cases
- Replacing a fragmented monitoring stack - A solo developer running GA, UptimeKuma, and Netdata on separate VMs consolidates all three into one Tianji Docker Compose deployment, reducing monthly server costs and dashboard context-switching.
- Tracking deployment telemetry for an OSS tool - An open-source CLI author embeds the Tianji telemetry badge in their README to count active deployments by geography without collecting personally identifiable information.
- Publishing a customer-facing status page - A small SaaS team uses Tianji’s status page with a custom domain to communicate uptime and planned maintenance to paying customers without building or hosting a separate status site.
- Monitoring LLM API spend across providers - A team using multiple AI providers routes all LLM traffic through the Tianji AI gateway to track token consumption, compute cost per request, and set quota alerts before bills arrive.
- Running automated site performance audits - A web agency schedules weekly Lighthouse audits against client URLs through Tianji’s Lighthouse integration and tracks Core Web Vitals trends over time without a separate CI pipeline.
- Collecting structured user feedback - A product team embeds Tianji surveys on key pages to gather NPS scores and feature requests, then uses the AI survey classification feature to automatically tag and route responses.
Under The Hood
Architecture Tianji is a TypeScript monorepo organized around a clear separation between the Node.js server, React client, shared type library, Go reporter binary, and auxiliary packages (CLI, client SDK, MCP server, React/React Native SDKs). The server layer uses Express.js with tRPC providing end-to-end type-safe RPC across all business domains, with trpc-to-openapi generating a full OpenAPI document at runtime. Separate Express routers handle high-throughput ingestion paths—telemetry, server status UDP, and the tracker endpoint—that bypass tRPC overhead. A ZeroMQ message queue decouples CPU-intensive work (Lighthouse Puppeteer audits, AI survey classification and translation) from HTTP request handlers. ClickHouse is an optional OLAP backend for analytics queries that exceed PostgreSQL’s aggregation performance. Distributed locking via a Keyv-backed implementation ensures that function worker cron jobs execute only once even in clustered deployments. The architecture cleanly partitions HTTP routing, business logic in a model layer, database access through Prisma, async processing through the MQ worker, and real-time push through Socket.io.
Tech Stack The server runs on Node.js with Express and TypeScript, using tRPC for internal API calls and Auth.js for authentication across email, OAuth, and API key flows. PostgreSQL is the primary database managed through Prisma ORM with Zod-derived runtime schema validation. ClickHouse provides optional high-throughput OLAP storage for website analytics events. ZeroMQ handles background task queuing for Lighthouse audits and AI-powered survey processing. The React 18 client is built with Vite, TanStack Router, and React Query for data fetching. The reporter is a statically linked Go binary using gopsutil to collect server metrics over UDP. Kubernetes deployment is supported via Helm charts, and one-click installers exist for Render, Sealos, Hostinger, and ClawCloud. Vitest runs the test suite with GitHub Actions managing CI across Docker build, reporter release, and unit test pipelines.
Code Quality The repository contains extensive test coverage across model files, routers, cronjobs, and utility modules, with snapshot testing, SQL assertion patterns, and integration mocks throughout. TypeScript is enforced comprehensively with Zod schemas providing runtime validation at API boundaries. Error handling is explicit: a custom Express error middleware with structured logging catches unhandled errors, Prometheus counters instrument key paths, and the batch writer abstraction provides graceful shutdown semantics for buffered writes. Conventional commits are enforced via release-it with automated changelog generation. Inline comments are present in moderately complex modules. A comprehensive documentation site under the website directory covers installation, API reference, monitor configuration, server status setup, telemetry, notifications, and AI router usage.
What Makes It Unique Tianji’s most technically distinctive capability is its multi-tenant AI gateway, which proxies requests across OpenAI, Anthropic, DeepSeek, and OpenRouter with per-request token counting, cost calculation using custom model pricing tables, TPOT (time per output token) measurement for streaming responses, and per-workspace quota alerting—functionality typically found only in dedicated LLM observability tools. Alongside this, the AI Router adds protocol-transparent provider switching between OpenAI Chat, OpenAI Responses, and Anthropic Messages APIs. The serverless FunctionWorker system combines isolated-vm sandboxed execution, cluster-safe distributed locking via Keyv, Monaco-editor-based code diff viewing for revision history, and audit log correlation—bringing programmable automation inside the observability platform. The optional ClickHouse backend, the Go UDP reporter for zero-dependency server metric collection, and the MCP server for AI assistant integration round out a platform that goes considerably beyond what its all-in-one positioning might suggest.
Self-Hosting
Tianji is released under the Apache License 2.0, which is a permissive open-source license. It allows commercial use, modification, distribution, and private use without requiring derived works to be open-sourced. The only obligations are preserving copyright and license notices. This makes it safe for organizations to self-host, modify, and integrate into internal tooling without concern about copyleft implications.
Running Tianji yourself requires a PostgreSQL database, Node.js 18+, and optionally Docker for the recommended deployment path. The provided Docker Compose file bundles the application and a PostgreSQL instance for single-node setups. For higher traffic, an optional ClickHouse instance can be added for analytics queries. The Go reporter binary must be installed on each server you want to monitor. You are responsible for database backups, schema migrations (handled by Prisma), SSL termination, and keeping up with frequent releases—the project ships multiple versions per week. Kubernetes Helm charts are available for teams that need horizontal scaling and container orchestration.
There is no official managed cloud version of Tianji, so every team self-hosts. This means there are no vendor-managed SLAs, no automatic backups, no 24/7 support contracts, and no HA failover unless you build it. Feature releases move quickly—over 260 versions have shipped since the project launched in mid-2023—which is a sign of active development but also means staying current requires attention. Community support is available through GitHub Issues, and the project maintainer is active, but enterprise-grade support engagements are not offered.
Related Apps
Uptime Kuma
Monitoring
Self-hosted monitoring for every service you run — 23 monitor types, 95 notification channels, live dashboards, and public status pages with no vendor lock-in.
Uptime Kuma
MITNetdata
Monitoring · Devops
Real-time per-second metrics, ML-powered anomaly detection, and zero-config observability for any infrastructure.
Netdata
GPL 3.0Grafana
Monitoring · Analytics
The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.