Skip to main content
A tenant summary answers questions that no single tenant can (such as “across all my tenants, which ones are in the busy band of abuse reports this week?”). Brussle publishes one document of band labels for each tenant into your template’s namespace each hour, and you read, query and judge those documents like any others. Brussle keeps each tenant’s namespace apart on purpose and nothing reads across namespaces, so a tenant summary is the one way to get data up from the tenants:
  1. A template publishes one tenant document for each namespace under it.
  2. Brussle writes these documents into the template’s own namespace.
  3. Each tenant document comes from that tenant’s groups, converted into bands.
Only band labels cross from a tenant to the template’s namespace:
  • A tenant document holds band labels, and never the value of an aggregate.
  • Key values come from your tenants’ attributes, and a tenant document holds only the key values that you list.
  • A judgment over tenant documents reads no text of a tenant, only the labels that each tenant published.
A tenant summary is not a relation, since no judgment reads across namespaces. The summary is a report that Brussle writes each hour, from each tenant up to the template’s namespace.

Set up a tenant summary

Here each tenant under acme/prod/* has two template groups:
  • abuse_by_day: its key is a day value that you write, and it keeps the last 7 days.
  • by_plan: its key is the plan.
Choose these settings:
  • groups: the groups that each tenant publishes.
  • bands: a band for each aggregate that you want to read.
  • keys: the key values that you want to publish one by one.
POST /v1/namespaces/acme%2Fprod%2F*/tenant_summary
  • Each group must exist on the template.
  • Each key of bands names one of the aggregates of these groups as <group>.<aggregate>, with the same name as in the group’s rows.
  • A value gets the label at the position equal to the number of cut points at or below it, so with cut points 10 and 100 the value 50 gets some. Each band setting has one more label than cut points.
  • keys is optional. Each group that it names must be in groups, with the key values that you want to see one by one.
Templates need the Team plan or above. The first run starts within the hour, and until then every tenant is pending.

What a tenant document holds

A run reads each tenant’s group rows each hour and writes the tenant’s document into the template’s namespace (here acme/prod):
  • id is the name of the tenant’s namespace, and attributes.kind is tenant.
  • state.groups holds only labels.
    • The all of each group gives the band of each aggregate over all its key values together (here, the abuse count over the 7 days that abuse_by_day keeps).
    • A group that you listed in keys also has keys, which holds the labels of each listed key value that the tenant has. This tenant has no free row, so free is absent.
    • An aggregate without a band does not show, and neither does a key value that you did not list.
  • state.source says where the labels came from, without any of the tenant’s data. as_of is the position in the tenant’s history at which the labels are exact.
  • state.published_at is when the run wrote the document.
A run writes a tenant’s document only when its labels changed, so a quiet tenant costs nothing to keep current. A tenant with no rows in any of its groups yet has no document.

Query your tenants

A tenant document is an ordinary document, so to read the bands of all your tenants, query the tenant documents with their state:
POST /v1/namespaces/acme%2Fprod/query
Each row holds one tenant’s labels in state.groups, and you page through the rows with next_cursor. A query cannot filter on state, so a query cannot choose tenants by band, and a subscription cannot watch a band. You have two choices:
  • Apply your rule in your own code. For example, list the tenants whose abuse_by_day band is busy, and compare the rows with the rows that you read last time to find a tenant that moved up a band.
  • Judge the tenant documents, since an answer is a field that queries and subscriptions can filter on. See judge your tenants.

Judge your tenants

One tenant document holds the bands of one moment, so one set of labels cannot show that abuse is rising. To ask about a change, add previous to the recipe, and the engine then sees the labels as the last answer saw them, beside the labels now:
POST /v1/namespaces/acme%2Fprod/judgments
  • When Brussle judges. Brussle judges a tenant document when the run writes it, which is when the tenant’s labels change. A write that changes no label that the judgment reads makes no engine call.
  • The first answer. The first evaluation of a tenant document has no previous labels, so the criteria tell the engine to answer no then.
  • Get told. A subscription on ["answers.abuse_moved_up.thresholds.moved_up", "Eq", true] sends subscription.entered when a tenant’s answer starts to hold the threshold, and subscription.exited when the answer stops holding it.
  • Thresholds. moved_up is 0.5, a starting value, so measure it with outcomes.
This judgment reads only its own document, so if a fixed rule on the labels is enough, apply it in your own code to the rows of the query. A judgment gives you an answer that you can filter, subscribe to and measure against outcomes, and each answer records the version of the question and the engine that made it. The evaluation of a tenant document shows the labels that the engine read, and goes no further back than the tenant document. state.source.as_of on the document is the position in the tenant’s history at which the labels are exact.

Check how current each tenant is

GET lists each tenant by name, with its status:
GET /v1/namespaces/acme%2Fprod%2F*/tenant_summary
A tenant document can be more than an hour late:
  • A group’s rows are at most about one hour behind the tenant’s writes.
  • The run reads the rows each hour, and goes through your tenants page by page.
A tenant document can trail its tenant by up to one run plus the time to page through the tenants, so do not assume one hour. Read published_at and source_as_of instead.

Change or stop it

  • Groups, bands and keys. Change them with PATCH, where each value that you send replaces the full setting. The next run rewrites each tenant document whose labels change, and Brussle judges each of those documents again. So a PATCH without "confirm": true changes nothing and returns what the change costs, with one line for each judgment on the template’s namespace that reads tenant documents. Send it again with "confirm": true, and the change applies from the next run with no more action from you.
  • Delete with DELETE. The runs stop, and the tenant documents stay as ordinary documents.

Tenants that come and go

  • A new tenant under the template gets its document at the first run after its groups first have rows.
  • When you delete a tenant and create it again with the same name, Brussle deletes its document and writes it again. The history of each judgment of that document splits at the new incarnation, as the tenant’s history does.
  • Brussle deletes a tenant document only when it has confirmed that the tenant’s namespace is deleted, and never only because a list did not show the tenant.

Billing and failures

Tenant documents are writes to the template’s namespace, so they bill your organization as writes and stored bytes, named tenant_summary in usage. Judgments over them bill as any judgment does, and a tenant with no changes writes nothing. When the template’s namespace refuses the writes (for example because it is over its budget with on_exceeded: reject):
  • The tenant summary shows the warning tenant_summary_failed.
  • The events feed has one namespace.tenant_summary_failed for the run, with the reason.
Nothing is lost, since the next run that can write catches up all the tenants and clears the warning.