This article explores the architectural trade-offs between building an in-house metrics dashboard backend using tools like PostgreSQL and Metabase versus integrating with a third-party metrics ingestion API for SaaS applications. It emphasizes distinguishing between raw event data for incident investigation and aggregate metrics for operational trends, guiding decisions based on business needs, team size, and the need for durable, traceable evidence.
Read original on Dev.to #architectureChoosing the right architecture for a metrics dashboard backend involves critical build vs. buy decisions, especially for lean SaaS teams. The core challenge is balancing the need for operational visibility (trends, counters) with the requirement for deep, reconstructable evidence for incident investigations. This article outlines two primary architectural paths, each with distinct advantages and trade-offs.
| System Shape | Best First Fit | Non-Negotiable Invariant | Main Cost |
|---|
The article highlights a crucial distinction: metrics answer "when and how much?" while durable events and logs answer "what happened to this customer?" This separation is fundamental to designing a robust observability system. Operational metrics, such as `exports_failed = 1`, signal an issue but don't provide the granular context needed for root cause analysis. For that, a system must retain detailed, immutable business events linked to specific tenants, requests, and deployments.
This approach involves using a relational database like PostgreSQL (e.g., managed by Supabase) as the primary store for detailed, reconstructable business events. Dashboards can then be built on top using tools like Metabase. This path is strong when incident investigations frequently require exact joins with other business data like subscriptions, jobs, or user records. The main trade-off is the operational overhead of managing schema, retention policies, indexing, and query load, which competes with product development hours for a small team.
This path recommends outsourcing the undifferentiated plumbing of continuous metric ingestion and aggregation to a specialized third-party API (e.g., Infrai, or more broadly, platforms like Prometheus/Grafana or Datadog). This is ideal for basic operational trends and counters. The critical invariant here is that reporting metrics must not block customer requests, and failed metric reports must not erase the original source event. Business events should still be durably stored elsewhere (e.g., in PostgreSQL). This approach reduces operational burden but may require companion tools for advanced alerting and deeper investigation.
Key Recommendation
For B2B SaaS MVPs, consider using an external metrics ingestion API for basic in-product charts to reduce development friction, while maintaining detailed, reconstructable business events in your application's database (like Postgres) for robust incident investigation. Treat metrics as an index to evidence, not the evidence itself.