perf: load console pages in time for organizations with many monitors
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m10s
ci / test (pull_request) Successful in 12m19s
ci / build (pull_request) Successful in 18m13s
ci / image (pull_request) Successful in 5m20s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m10s
ci / test (pull_request) Successful in 12m19s
ci / build (pull_request) Successful in 18m13s
ci / image (pull_request) Successful in 5m20s
Every console page that shows monitor status (monitors, incidents, monitor details, evidence) went through one loader that read, for all of the organization's monitors: - the newest result per monitor and region, by scanning a day of raw results; - the bars of the selected range, from raw results for ranges up to 24h, though only one page of monitors is shown; - when each monitor first reported, scanning two days of results. With 3000 monitors that took about a second, growing with the number of results. Now: - latest_results keeps the newest result per monitor and region, updated as results are stored (migration 00055 fills it from the last day); - bars are loaded only for the monitors a page shows; - first data is loaded per monitor on its page, and the monitor list asks only for the organization's earliest data, by index; - monitor, region and incident queries name the organization, so their indexes are used instead of row security filtering whole tables. Public status pages also read only their own monitors' latest results and hourly buckets instead of the whole organization's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
2a440b9c5e
commit
1138d555aa
22 files changed
+630
-182
No files matched your search
@@ -39,7 +39,7 @@ type Querier interface {
|
||||
// System scope: the receiver a webhook token belongs to.
|
||||
AlertmanagerReceiverByHash(ctx context.Context, tokenHash []byte) (AlertmanagerReceiverByHashRow, error)
|
||||
AllMonitorAlertGroups(ctx context.Context) ([]MonitorAlertGroup, error)
|
||||
AllMonitorRegions(ctx context.Context) ([]AllMonitorRegionsRow, error)
|
||||
AllMonitorRegions(ctx context.Context, orgID uuid.UUID) ([]AllMonitorRegionsRow, error)
|
||||
AnyUserExists(ctx context.Context) (bool, error)
|
||||
// How much one instance checked for the organization in the last hour.
|
||||
CheckerStats(ctx context.Context, arg CheckerStatsParams) (CheckerStatsRow, error)
|
||||
@@ -124,6 +124,12 @@ type Querier interface {
|
||||
// for two days, after which only the verify button tries again. A verified
|
||||
// one is checked daily, hourly once its record went missing.
|
||||
DomainsToCheck(ctx context.Context, arg DomainsToCheckParams) ([]DomainsToCheckRow, error)
|
||||
// The day the organization's monitors first reported, if any did.
|
||||
EarliestDataDaily(ctx context.Context, orgID uuid.UUID) (time.Time, error)
|
||||
// When the organization's monitors first reported since $2, exactly: the
|
||||
// first result of each monitor is found through its index, so the cost
|
||||
// does not grow with the days of results.
|
||||
EarliestDataRecent(ctx context.Context, arg EarliestDataRecentParams) (time.Time, error)
|
||||
EmailKeyTaken(ctx context.Context, emailKey *string) (bool, error)
|
||||
EnableTOTP(ctx context.Context, arg EnableTOTPParams) error
|
||||
EnqueueNotification(ctx context.Context, arg EnqueueNotificationParams) error
|
||||
@@ -139,9 +145,9 @@ type Querier interface {
|
||||
// FiringAlerts newest first, a page from a keyset cursor (see paging.go)
|
||||
// whose string key is the fingerprint.
|
||||
FiringAlertsPage(ctx context.Context, arg FiringAlertsPageParams) ([]FiringAlertsPageRow, error)
|
||||
// When each monitor and region first reported, to the day.
|
||||
FirstDataDaily(ctx context.Context, orgID uuid.UUID) ([]FirstDataDailyRow, error)
|
||||
// When each monitor and region first reported since $2, exactly. Used for
|
||||
// When each region of a monitor first reported, to the day.
|
||||
FirstDataDaily(ctx context.Context, arg FirstDataDailyParams) ([]FirstDataDailyRow, error)
|
||||
// When each region of a monitor first reported since $3, exactly. Used for
|
||||
// data younger than the daily aggregate's resolution.
|
||||
FirstDataRecent(ctx context.Context, arg FirstDataRecentParams) ([]FirstDataRecentRow, error)
|
||||
// Keeps organization and platform entries readable as "deleted user" but
|
||||
@@ -184,8 +190,8 @@ type Querier interface {
|
||||
// Per monitor and hour since $2, across all regions.
|
||||
HourlyBuckets(ctx context.Context, arg HourlyBucketsParams) ([]HourlyBucketsRow, error)
|
||||
IncidentsForMonitors(ctx context.Context, arg IncidentsForMonitorsParams) ([]Incident, error)
|
||||
// Incidents overlapping the time since $1, for SLA calculation.
|
||||
IncidentsSince(ctx context.Context, resolvedAt *time.Time) ([]IncidentsSinceRow, error)
|
||||
// Incidents overlapping the time since $2, for SLA calculation.
|
||||
IncidentsSince(ctx context.Context, arg IncidentsSinceParams) ([]IncidentsSinceRow, error)
|
||||
InsertAuditEvent(ctx context.Context, arg InsertAuditEventParams) error
|
||||
// check_results and its aggregates have no row-level security (see
|
||||
// migration 00013). Every query here must filter by org_id.
|
||||
@@ -196,9 +202,11 @@ type Querier interface {
|
||||
IsMember(ctx context.Context, arg IsMemberParams) (bool, error)
|
||||
LastFailureEvidence(ctx context.Context, arg LastFailureEvidenceParams) (LastFailureEvidenceRow, error)
|
||||
LatestResultForMonitor(ctx context.Context, arg LatestResultForMonitorParams) (LatestResultForMonitorRow, error)
|
||||
// Newest result per monitor and region in the org.
|
||||
// Newest result per monitor and region in the org, of the last day.
|
||||
LatestResults(ctx context.Context, orgID uuid.UUID) ([]LatestResultsRow, error)
|
||||
LatestResultsForMonitor(ctx context.Context, arg LatestResultsForMonitorParams) ([]LatestResultsForMonitorRow, error)
|
||||
// LatestResults limited to the monitors ids.
|
||||
LatestResultsForMonitors(ctx context.Context, arg LatestResultsForMonitorsParams) ([]LatestResultsForMonitorsRow, error)
|
||||
LegalAcceptances(ctx context.Context, userID uuid.UUID) ([]LegalAcceptancesRow, error)
|
||||
// The organization's documents and the platform's, organization first.
|
||||
LegalDocuments(ctx context.Context, orgID *uuid.UUID) ([]LegalDocument, error)
|
||||
@@ -229,7 +237,8 @@ type Querier interface {
|
||||
// Latest start first, a page from a keyset cursor (see paging.go).
|
||||
ListMaintenancePage(ctx context.Context, arg ListMaintenancePageParams) ([]MaintenanceWindow, error)
|
||||
ListMaintenanceTargets(ctx context.Context) ([]MaintenanceTarget, error)
|
||||
ListMonitors(ctx context.Context) ([]Monitor, error)
|
||||
// The org filter, though row security implies it, lets the index be used.
|
||||
ListMonitors(ctx context.Context, orgID uuid.UUID) ([]Monitor, error)
|
||||
// By name, a page from a keyset cursor (see paging.go).
|
||||
ListMonitorsPage(ctx context.Context, arg ListMonitorsPageParams) ([]Monitor, error)
|
||||
ListOrgMembers(ctx context.Context, orgID uuid.UUID) ([]ListOrgMembersRow, error)
|
||||
@@ -291,7 +300,7 @@ type Querier interface {
|
||||
// System scope.
|
||||
NotificationDetails(ctx context.Context, ids []uuid.UUID) ([]NotificationDetailsRow, error)
|
||||
OpenIncident(ctx context.Context, arg OpenIncidentParams) (Incident, error)
|
||||
OpenIncidents(ctx context.Context) ([]Incident, error)
|
||||
OpenIncidents(ctx context.Context, orgID uuid.UUID) ([]Incident, error)
|
||||
OrgAssignmentsExport(ctx context.Context, orgID uuid.UUID) ([]OrgAssignmentsExportRow, error)
|
||||
OrgAuditExport(ctx context.Context, orgID uuid.UUID) ([]OrgAuditExportRow, error)
|
||||
OrgDailyStats(ctx context.Context, orgID uuid.UUID) ([]OrgDailyStatsRow, error)
|
||||
@@ -417,6 +426,11 @@ type Querier interface {
|
||||
UpdateStatusPage(ctx context.Context, arg UpdateStatusPageParams) (StatusPage, error)
|
||||
UpdateStatusPageGroup(ctx context.Context, arg UpdateStatusPageGroupParams) (StatusPageGroup, error)
|
||||
UpsertAlertmanagerAlert(ctx context.Context, arg UpsertAlertmanagerAlertParams) error
|
||||
// latest_results holds the newest check result per monitor and region
|
||||
// (see migration 00055) and has row-level security.
|
||||
// Keeps the newest of rows, a JSON array of results, per monitor and
|
||||
// region; results arriving late do not replace newer ones.
|
||||
UpsertLatestResults(ctx context.Context, rows []byte) error
|
||||
// A new version starts when the document is created or when the edit asks
|
||||
// everyone to accept it again.
|
||||
UpsertLegalDocument(ctx context.Context, arg UpsertLegalDocumentParams) error
|
||||
|
||||
Reference in new issue
Block a user