Video in progress

In a multi-tenant SaaS, one big customer keeps complaining "it's always slow for us", while the overall SLO is green. How do you build observability at the tenant level?

The overall SLO hides the big customer's problem under the traffic of the small customers. I make the tenant ID a mandatory attribute on traces and logs, and use it in metrics only in a limited form (top tenants or tier). For important customers I set separate SLIs and SLOs.

📖 Answer

For example, there are 2000 tenants, one of them produces 3% of the traffic, and 20% of its requests are slow. In the overall latency SLI that is 0.6%, so a 99% SLO stays green. For the customer, every fifth request is slow.

The layers:

Traces and logs: tenant.id is mandatory on every span and log line. It is determined at the entry point and passed through the whole flow via baggage. Cardinality is not a problem here. When a complaint arrives, the first step is to open that tenant's slow traces.

Metrics: adding a tenant_id label to every metric causes a series explosion across 2000 tenants × endpoint × status × bucket. The options:

  • tenant_tier (free, pro, enterprise): low cardinality, everywhere;
  • a tenant_id label only for enterprise tenants (say, 50 of them) and other for the rest, done in a MeterFilter or an Observation convention;
  • computing the per-tenant SLI offline from wide event or span data, not from metrics.
// tag enterprise tenants separately and lump the rest together
String tenantTag = enterpriseTenants.contains(tenantId) ? tenantId : "other";
observation.lowCardinalityKeyValue("tenant", tenantTag);

Tenant SLOs: for customers with an SLA in their contract, a separate SLI, a separate error budget and an alert. Sometimes this is a contract requirement: you have to give the customer a monthly report.

What the cause often is: the big tenant has a lot of data, so a query that doesn't use an index, large pagination, or a "noisy neighbor" on a resource shared with other tenants. So per-tenant resource consumption (DB time, CPU per tenant) is also a useful signal, and later it becomes evidence for a decision about tenant isolation or a separate shard.

There is a security side too: if per-tenant dashboards are shown to the customer, you have to check that no other tenant's data leaks.