AlertRuleService — DDL appendix¶
Generated from the architecture model
This page is rendered from model/**/*.yaml by tools/docs_model during mkdocs build. Edit the YAML, not this page; hand-written design lives on the linked service, platform and plane pages.
Dialect shown: SQL Server (nvarchar, uniqueidentifier, datetimeoffset). Migrations are authored as FluentMigrator classes in the service's DatabaseModel.Migrations project; the TenantId column and the NHibernate tenant filter follow canonical ADR-0100 in SharedDb mode.
dbo.AlertRules¶
Owner: AlertRule
CREATE TABLE [dbo].[AlertRules] (
[RuleId] uniqueidentifier NOT NULL,
[TenantId] nvarchar(64) NOT NULL,
[Name] nvarchar(128) NOT NULL,
[SourceKind] int NOT NULL,
[ConditionJson] nvarchar(2000) NOT NULL,
[Severity] int NOT NULL,
[DedupKeyTemplate] nvarchar(256) NOT NULL,
[RoutesJson] nvarchar(1024) NOT NULL,
[SuppressionJson] nvarchar(512) NULL,
[Active] bit NOT NULL DEFAULT (1),
CONSTRAINT [PK_AlertRules] PRIMARY KEY ([RuleId])
);
CREATE UNIQUE INDEX [UX_AlertRules_Tenant_Name] ON [dbo].[AlertRules] ([TenantId], [Name]);
| Column | Type | Null | Key | Description |
|---|---|---|---|---|
RuleId |
uniqueidentifier |
no | PK | |
TenantId |
nvarchar(64) |
no | ||
Name |
nvarchar(128) |
no | ||
SourceKind |
int |
no | ||
ConditionJson |
nvarchar(2000) |
no | ||
Severity |
int |
no | ||
DedupKeyTemplate |
nvarchar(256) |
no | ||
RoutesJson |
nvarchar(1024) |
no | ||
SuppressionJson |
nvarchar(512) |
yes | ||
Active |
bit |
no |
dbo.AlertInstances¶
Owner: AlertInstance · Retention: 13 months
CREATE TABLE [dbo].[AlertInstances] (
[AlertId] uniqueidentifier NOT NULL,
[TenantId] nvarchar(64) NOT NULL,
[RuleId] uniqueidentifier NOT NULL,
[DedupKey] nvarchar(256) NOT NULL,
[Severity] int NOT NULL,
[SourceRef] nvarchar(256) NOT NULL,
[State] int NOT NULL,
[FiredAt] datetimeoffset NOT NULL,
[AcknowledgedBy] nvarchar(256) NULL,
[ResolvedAt] datetimeoffset NULL,
[NotificationsJson] nvarchar(max) NOT NULL,
CONSTRAINT [PK_AlertInstances] PRIMARY KEY ([AlertId])
);
ALTER TABLE [dbo].[AlertInstances] ADD CONSTRAINT [FK_AlertInstances_AlertRules_RuleId] FOREIGN KEY ([RuleId]) REFERENCES [dbo].[AlertRules] ([RuleId]);
CREATE INDEX [IX_Alerts_Tenant_State] ON [dbo].[AlertInstances] ([TenantId], [State], [Severity]);
CREATE INDEX [IX_Alerts_Dedup_Open] ON [dbo].[AlertInstances] ([TenantId], [DedupKey], [State]);
| Column | Type | Null | Key | Description |
|---|---|---|---|---|
AlertId |
uniqueidentifier |
no | PK | |
TenantId |
nvarchar(64) |
no | ||
RuleId |
uniqueidentifier |
no | FK → AlertRules.RuleId | |
DedupKey |
nvarchar(256) |
no | ||
Severity |
int |
no | ||
SourceRef |
nvarchar(256) |
no | ||
State |
int |
no | ||
FiredAt |
datetimeoffset |
no | ||
AcknowledgedBy |
nvarchar(256) |
yes | ||
ResolvedAt |
datetimeoffset |
yes | ||
NotificationsJson |
nvarchar(max) |
no |