feat: show unchecked monitors and tell about regions without checkers
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m17s
ci / test (pull_request) Successful in 12m7s
ci / build (pull_request) Successful in 19m34s
ci / image (pull_request) Successful in 3m15s

A region whose checkers had all gone left its monitors looking up: the
console and status pages took the last result, however old, and nobody
was told.

- A region's last result counts only while it is younger than the
  evaluator's staleness (3 intervals, at least 2 minutes); older ones
  show as "no data since …" in the console and leave status page
  components unknown instead of operational.
- A monitor no region has reported for recently is marked "not being
  checked", counted on the dashboard with an explanation, and noted on
  its page.
- A region watch on every API replica emails the platform's admins
  (platform regions) or the organization's owners (own regions) once a
  region with checkers and enabled monitors has had no live checker for
  UPTIME_REGION_ALERT_AFTER (default 5m), and again when one is back.
  The dashboard names such regions at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-24 23:35:43 +01:00
1 parent f3d0a4c844
commit dc2e21f964
18 files changed
+3272 -2652

No files matched your search

+70
View File
@@ -318,6 +318,32 @@ func (q *Queries) ListVisibleRegions(ctx context.Context) ([]Region, error) {
return items, nil
}
const orgOwnerEmails = `-- name: OrgOwnerEmails :many
SELECT u.email FROM memberships m JOIN users u ON u.id = m.user_id
WHERE m.org_id = $1 AND m.is_owner AND u.disabled_at IS NULL
`
// System scope.
func (q *Queries) OrgOwnerEmails(ctx context.Context, orgID uuid.UUID) ([]string, error) {
rows, err := q.db.Query(ctx, orgOwnerEmails, orgID)
if err != nil {
return nil, err
}
defer rows.Close()
items := []string{}
for rows.Next() {
var email string
if err := rows.Scan(&email); err != nil {
return nil, err
}
items = append(items, email)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const orgServesOwnPages = `-- name: OrgServesOwnPages :one
SELECT EXISTS (
SELECT 1 FROM agents
@@ -334,6 +360,50 @@ func (q *Queries) OrgServesOwnPages(ctx context.Context, orgID *uuid.UUID) (bool
return exists, err
}
const regionsToWatch = `-- name: RegionsToWatch :many
SELECT r.id, r.name, r.org_id, o.name AS org_name
FROM regions r
LEFT JOIN orgs o ON o.id = r.org_id
WHERE EXISTS (SELECT 1 FROM agents a WHERE a.kind = 'checker' AND a.region_id = r.id)
AND EXISTS (SELECT 1 FROM monitor_regions mr JOIN monitors m ON m.id = mr.monitor_id
WHERE mr.region_id = r.id AND m.enabled)
ORDER BY r.name
`
type RegionsToWatchRow struct {
ID uuid.UUID
Name string
OrgID *uuid.UUID
OrgName *string
}
// System scope: regions that have checkers and enabled monitors, so a
// region without a live checker leaves monitors unchecked.
func (q *Queries) RegionsToWatch(ctx context.Context) ([]RegionsToWatchRow, error) {
rows, err := q.db.Query(ctx, regionsToWatch)
if err != nil {
return nil, err
}
defer rows.Close()
items := []RegionsToWatchRow{}
for rows.Next() {
var i RegionsToWatchRow
if err := rows.Scan(
&i.ID,
&i.Name,
&i.OrgID,
&i.OrgName,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const setAgentAllowPrivate = `-- name: SetAgentAllowPrivate :execrows
UPDATE agents SET allow_private = $1
WHERE id = $2 AND kind = 'checker' AND org_id = $3
+5
View File
@@ -289,6 +289,8 @@ type Querier interface {
OrgIncidentUpdatesExport(ctx context.Context, orgID uuid.UUID) ([]OrgIncidentUpdatesExportRow, error)
OrgIncidentsExport(ctx context.Context, orgID uuid.UUID) ([]OrgIncidentsExportRow, error)
OrgMembersExport(ctx context.Context, orgID uuid.UUID) ([]OrgMembersExportRow, error)
// System scope.
OrgOwnerEmails(ctx context.Context, orgID uuid.UUID) ([]string, error)
// An organization serves its status pages itself once one of its own
// status page servers has connected.
OrgServesOwnPages(ctx context.Context, orgID *uuid.UUID) (bool, error)
@@ -321,6 +323,9 @@ type Querier interface {
RegionBuckets(ctx context.Context, arg RegionBucketsParams) ([]RegionBucketsRow, error)
RegionBucketsDaily(ctx context.Context, arg RegionBucketsDailyParams) ([]RegionBucketsDailyRow, error)
RegionBucketsHourly(ctx context.Context, arg RegionBucketsHourlyParams) ([]RegionBucketsHourlyRow, error)
// System scope: regions that have checkers and enabled monitors, so a
// region without a live checker leaves monitors unchecked.
RegionsToWatch(ctx context.Context) ([]RegionsToWatchRow, error)
RegroupMonitors(ctx context.Context, arg RegroupMonitorsParams) error
RemoveMembership(ctx context.Context, arg RemoveMembershipParams) (int64, error)
// Moves the subgroups of a group that is about to be deleted.
+16
View File
@@ -62,3 +62,19 @@ SELECT EXISTS (
SELECT 1 FROM agents
WHERE org_id = $1 AND kind = 'statuspage' AND last_seen_at IS NOT NULL
);
-- name: RegionsToWatch :many
-- System scope: regions that have checkers and enabled monitors, so a
-- region without a live checker leaves monitors unchecked.
SELECT r.id, r.name, r.org_id, o.name AS org_name
FROM regions r
LEFT JOIN orgs o ON o.id = r.org_id
WHERE EXISTS (SELECT 1 FROM agents a WHERE a.kind = 'checker' AND a.region_id = r.id)
AND EXISTS (SELECT 1 FROM monitor_regions mr JOIN monitors m ON m.id = mr.monitor_id
WHERE mr.region_id = r.id AND m.enabled)
ORDER BY r.name;
-- name: OrgOwnerEmails :many
-- System scope.
SELECT u.email FROM memberships m JOIN users u ON u.id = m.user_id
WHERE m.org_id = $1 AND m.is_owner AND u.disabled_at IS NULL;
+2 -1
View File
@@ -38,7 +38,8 @@ DELETE FROM status_pages WHERE id = $1;
-- name: StatusPageMonitors :many
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id,
m.type AS monitor_type, m.interval_seconds
FROM status_page_monitors spm
JOIN monitors m ON m.id = spm.monitor_id
WHERE spm.page_id = $1
+14 -9
View File
@@ -454,7 +454,8 @@ func (q *Queries) SetStatusPageMonitorGroup(ctx context.Context, arg SetStatusPa
const statusPageMonitors = `-- name: StatusPageMonitors :many
SELECT spm.monitor_id, spm.section, spm.group_id, spm.label, spm.position,
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id
m.name AS monitor_name, m.enabled, m.group_id AS monitor_group_id,
m.type AS monitor_type, m.interval_seconds
FROM status_page_monitors spm
JOIN monitors m ON m.id = spm.monitor_id
WHERE spm.page_id = $1
@@ -462,14 +463,16 @@ ORDER BY spm.position, m.name
`
type StatusPageMonitorsRow struct {
MonitorID uuid.UUID
Section string
GroupID *uuid.UUID
Label string
Position int32
MonitorName string
Enabled bool
MonitorGroupID *uuid.UUID
MonitorID uuid.UUID
Section string
GroupID *uuid.UUID
Label string
Position int32
MonitorName string
Enabled bool
MonitorGroupID *uuid.UUID
MonitorType string
IntervalSeconds int32
}
func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]StatusPageMonitorsRow, error) {
@@ -490,6 +493,8 @@ func (q *Queries) StatusPageMonitors(ctx context.Context, pageID uuid.UUID) ([]S
&i.MonitorName,
&i.Enabled,
&i.MonitorGroupID,
&i.MonitorType,
&i.IntervalSeconds,
); err != nil {
return nil, err
}