Repository navigation
feat: multi-tenant daemon isolation - #732
Merged
Merged
Conversation
…use one wildcard stream
… tenant directories
…x alert state per tenant
…am sessions, and keep disposition ids per tenant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #358.
rsigma engine daemoncan serve several tenants in one process while keeping their state, API views, and sink output apart. Tenancy is off by default, and with it off, path-mode output and existing daemon behavior are unchanged.daemon.input.tenantfor a pull source, or adaemon.input.nats_tenantssubscription. Event fields, client headers, NATS message headers, and OTLP attributes are never identity. A token declares exactly one oftenant: <id>orall_tenants: true. A tenant id is 1 to 64 ASCII letters, digits,_, and-, starts with a letter or digit, and must be unique ignoring case.tenants. Version 1 snapshots load as the untenanted bucket, and a restore discards entries that do not match the current tenancy mode.tenantsbinding receives only those tenants' events. An unbound ruleset receives every tenant's events, with its state still keyed per tenant.daemon.tenancy.quotascaps correlation state, active alerts, incidents, and risk entities per tenant. At a tenant's cap, a new entry evicts that tenant's expired entries first, then its stalest ones. Joining an open incident never evicts. A restore or reload trims each tenant to its quota, and the global caps remain as a backstop. Thesilences,inhibition_sources, andstream_sessionsquotas refuse a tenant's new dynamic silence (429), inhibition source, or tap and tail session (409) at its cap. Disposition idempotency ids are kept per tenant, so one tenant's volume cannot evict another's.403on operator-only routes that span tenants, tenant-scoped reads are filtered to the token's tenant, and a resource owned by another tenant is404. Silences and dispositions written by a tenant token are bound to its tenant, and anall_tenantstoken must name a tenant on a write. Silence ids are unique per tenant: a duplicate is409, and anall_tenantsdelete of an id that several tenants use is409unless?tenant=names one. The audit trail records anall_tenantswrite under the tenant it affected, so that tenant's audit reads include it.tenant=<id>, route NATS subjects with{tenant}as a whole token into one wildcard JetStream stream, and route file paths with{tenant}as a whole path component. Per-tenant file sinks create the tenant's directory, keep a bounded handle LRU (max_open), and resume a retried delivery without rewriting lines. A result without a tenant on a{tenant}sink fails the batch before any write and reaches the DLQ. OTLP sinks carrytenant_idas a log-record attribute.scope.tenantslimits an enricher or webhook to listed tenants. An HTTP enricher URL template cannot place the tenant in the scheme, credentials, host, or port, and the HTTP response cache keys on the rendered headers, so a per-tenant header never shares a cached response.nats_tenantssubjects, with a project config layer, and with a ruleset binding that no token or source can produce. With tenancy off, it refuses any tenant binding, quota,{tenant}ortenant=sink, orscope.tenants.rsigma_tenant_rejected_total,rsigma_tenant_quota_evictions_total, andrsigma_detection_matches_by_tenant_total. The last buckets tenants outsidedaemon.tenancy.metrics_tenant_allowlistunderother.rsigma_rule_false_positive_ratiosums each rule across tenants.create_silenceandpost_dispositionaccept an optionaltenantargument; a tenant-bound token naming another tenant gets403. The docs recommend one tenant-bound bridge per tenant and a read-only bridge for anall_tenantstoken.Breaking.
RuleHeader.tenant_id,RawEvent.tenant,CorrelationSnapshot.tenants,GroupStateInfo.tenant,RulesetUnit.tenants,RulesetStats.tenants,CorrelationConfig.require_tenantandmax_state_entries_per_tenant, bothScopeConfig.tenants,RulesetBinding.tenants, andCacheKey.headers_hashneed defaults in struct literals.CaptureRing::snapshot_incidenttakes a tenant,DispositionStore::restoretakes the tenancy mode, and the alert-pipeline and risk config errors gainNatsSubjectvariants.SilenceStore::remove_scopedreturnsSilenceRemoval, andSilenceStore::try_addalso refuses a duplicate id.Test plan
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo doc --workspace --all-features --locked --no-depscargo test --workspace --all-features --locked, including the end-to-end isolation suite incrates/rsigma-cli/tests/cli_daemon_tenancy.rscargo check --manifest-path fuzz/Cargo.toml --all-targets --lockedpython3 scripts/mcp-smoke.py --bin target/debug/rsigmaand the same with--httpnpm run docs:buildandnpm run docs:validate