Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Clarify mixed-source monitored system status summaries

rcourtman919187776b6c
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 0b83bb09d3..72711746f0 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -248,6 +248,10 @@ copy: `/api/license/monitored-system-ledger` must preserve the canonical
summary plus the ordered reason list from unified resources, including the
degraded source or surface, its status, and its last-seen timestamp, so mixed
fresh/stale grouped systems remain explainable through one governed API shape.
+That canonical summary must also carry the mixed-source freshness explanation
+when the freshest grouped observation came from a different source than the
+degraded one, so API consumers can show a fresh `Last Seen` value without
+making warning or offline state look contradictory.
That client contract must also fail closed when older or partial payloads omit
the nested explanation object: the frontend may normalize missing explanation
fields to empty reasons/surfaces plus a safe default summary, but it must not
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index a9489e649b..df18fd7228 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -179,6 +179,11 @@ source freshness state, including which source or surface degraded and the
corresponding last-seen timestamp. Billing and support surfaces must consume
that shared reason list instead of trying to infer why a fresh overall
`last_seen` can still coincide with warning status.
+That shared summary must also explain mixed-source freshness directly when one
+grouped source reported more recently than the degraded one, so consumers do
+not present a fresh `Last Seen` timestamp beside warning or offline state
+without the canonical explanation of which grouped source is still reporting
+and which one drifted stale or disconnected.
The unified-resource runtime now also owns the durable change timeline for the
canonical resource view. `internal/unifiedresources/monitor_adapter.go` feeds
diff --git a/internal/unifiedresources/monitored_systems.go b/internal/unifiedresources/monitored_systems.go
index 75f2d971c4..e79a4fbe04 100644
--- a/internal/unifiedresources/monitored_systems.go
+++ b/internal/unifiedresources/monitored_systems.go
@@ -193,7 +193,7 @@ func monitoredSystemRecord(group monitoredSystemGroup) MonitoredSystemRecord {
}
record.StatusExplanation = normalizeMonitoredSystemStatusExplanation(record.StatusExplanation)
if record.StatusExplanation.Summary == "" {
- record.StatusExplanation.Summary = monitoredSystemStatusSummary(record.Status, record.StatusExplanation.Reasons)
+ record.StatusExplanation.Summary = monitoredSystemStatusSummary(group.resources, record.Status, record.StatusExplanation.Reasons)
}
if record.Source == "" {
record.Source = "unknown"
@@ -453,7 +453,7 @@ func monitoredSystemStatusExplanation(
) MonitoredSystemStatusExplanation {
reasons := monitoredSystemStatusReasons(resources)
return normalizeMonitoredSystemStatusExplanation(MonitoredSystemStatusExplanation{
- Summary: monitoredSystemStatusSummary(status, reasons),
+ Summary: monitoredSystemStatusSummary(resources, status, reasons),
Reasons: reasons,
})
}
@@ -569,7 +569,15 @@ func normalizeMonitoredSystemSourceStatus(status string) string {
}
}
-func monitoredSystemStatusSummary(status ResourceStatus, reasons []MonitoredSystemStatusReason) string {
+func monitoredSystemStatusSummary(
+ resources []*Resource,
+ status ResourceStatus,
+ reasons []MonitoredSystemStatusReason,
+) string {
+ if summary := monitoredSystemMixedStateStatusSummary(resources, status, reasons); summary != "" {
+ return summary
+ }
+
switch status {
case StatusOnline:
return "All included top-level collection paths currently report online status."
@@ -589,6 +597,38 @@ func monitoredSystemStatusSummary(status ResourceStatus, reasons []MonitoredSyst
}
}
+type monitoredSystemLatestObservation struct {
+ Name string
+ Source string
+ LastSeen time.Time
+}
+
+func monitoredSystemMixedStateStatusSummary(
+ resources []*Resource,
+ status ResourceStatus,
+ reasons []MonitoredSystemStatusReason,
+) string {
+ if len(reasons) == 0 || (status != StatusWarning && status != StatusOffline) {
+ return ""
+ }
+
+ degraded := reasons[0]
+ if degraded.LastSeen.IsZero() {
+ return ""
+ }
+
+ latest := monitoredSystemLatestOnlineObservation(resources)
+ if latest.LastSeen.IsZero() || !latest.LastSeen.After(degraded.LastSeen) {
+ return ""
+ }
+
+ return "Pulse most recently heard from " +
+ monitoredSystemStatusSourceLabel(latest.Source) + " for " + latest.Name +
+ " at " + latest.LastSeen.UTC().Format(time.RFC3339) +
+ ", but " + monitoredSystemStatusReasonClause(degraded) +
+ ", so this monitored system is " + string(status) + "."
+}
+
func monitoredSystemHasReasonStatus(reasons []MonitoredSystemStatusReason, status string) bool {
for _, reason := range reasons {
if reason.Status == status {
@@ -598,6 +638,53 @@ func monitoredSystemHasReasonStatus(reasons []MonitoredSystemStatusReason, statu
return false
}
+func monitoredSystemLatestOnlineObservation(resources []*Resource) monitoredSystemLatestObservation {
+ var latest monitoredSystemLatestObservation
+ for _, resource := range resources {
+ if resource == nil {
+ continue
+ }
+
+ name := monitoredSystemResourceDisplayName(resource)
+ if name == "" {
+ name = "Unnamed source"
+ }
+
+ if len(resource.SourceStatus) > 0 {
+ sourceKeys := make([]DataSource, 0, len(resource.SourceStatus))
+ for source := range resource.SourceStatus {
+ sourceKeys = append(sourceKeys, source)
+ }
+ sort.Slice(sourceKeys, func(i, j int) bool {
+ return sourceKeys[i] < sourceKeys[j]
+ })
+ for _, source := range sourceKeys {
+ sourceStatus := resource.SourceStatus[source]
+ if normalizeMonitoredSystemSourceStatus(sourceStatus.Status) != "online" {
+ continue
+ }
+ if latest.LastSeen.IsZero() || sourceStatus.LastSeen.After(latest.LastSeen) {
+ latest = monitoredSystemLatestObservation{
+ Name: name,
+ Source: string(source),
+ LastSeen: sourceStatus.LastSeen,
+ }
+ }
+ }
+ }
+
+ if normalizeMonitoredSystemSourceStatus(string(resource.Status)) == "online" &&
+ (latest.LastSeen.IsZero() || resource.LastSeen.After(latest.LastSeen)) {
+ latest = monitoredSystemLatestObservation{
+ Name: name,
+ Source: monitoredSystemPrimarySource(resource),
+ LastSeen: resource.LastSeen,
+ }
+ }
+ }
+ return latest
+}
+
func monitoredSystemStatusReasonPriority(reason MonitoredSystemStatusReason) int {
switch reason.Status {
case "offline":
@@ -611,6 +698,40 @@ func monitoredSystemStatusReasonPriority(reason MonitoredSystemStatusReason) int
}
}
+func monitoredSystemStatusReasonClause(reason MonitoredSystemStatusReason) string {
+ subject := reason.Name
+ if strings.TrimSpace(subject) == "" {
+ subject = "this monitored system"
+ }
+
+ sourceLabel := monitoredSystemStatusSourceLabel(reason.Source)
+ switch reason.Kind {
+ case "source-stale":
+ return sourceLabel + " data for " + subject + " is stale (last reported " + reason.LastSeen.UTC().Format(time.RFC3339) + ")"
+ case "source-offline":
+ return sourceLabel + " data for " + subject + " is offline or disconnected" + monitoredSystemStatusLastSeenSuffix(reason.LastSeen)
+ case "source-unknown":
+ return sourceLabel + " data for " + subject + " does not report a canonical status yet" + monitoredSystemStatusLastSeenSuffix(reason.LastSeen)
+ case "surface-stale":
+ return monitoredSystemGroupingTypeLabel(reason.Type) + " view for " + subject + " currently reports warning status from " + sourceLabel + monitoredSystemStatusLastSeenSuffix(reason.LastSeen)
+ case "surface-offline":
+ return monitoredSystemGroupingTypeLabel(reason.Type) + " view for " + subject + " currently reports offline status from " + sourceLabel + monitoredSystemStatusLastSeenSuffix(reason.LastSeen)
+ case "surface-unknown":
+ return monitoredSystemGroupingTypeLabel(reason.Type) + " view for " + subject + " currently reports unknown status from " + sourceLabel + monitoredSystemStatusLastSeenSuffix(reason.LastSeen)
+ default:
+ clause := strings.TrimSpace(reason.Summary)
+ clause = strings.TrimSuffix(clause, ".")
+ return clause
+ }
+}
+
+func monitoredSystemStatusLastSeenSuffix(lastSeen time.Time) string {
+ if lastSeen.IsZero() {
+ return ""
+ }
+ return " (last reported " + lastSeen.UTC().Format(time.RFC3339) + ")"
+}
+
func monitoredSystemStatusPriority(status ResourceStatus) int {
switch status {
case StatusWarning:
diff --git a/internal/unifiedresources/registry_test.go b/internal/unifiedresources/registry_test.go
index 9825bf7c5c..44a3b8ed04 100644
--- a/internal/unifiedresources/registry_test.go
+++ b/internal/unifiedresources/registry_test.go
@@ -303,6 +303,9 @@ func TestMonitoredSystemsExplainsStaleGroupedSourceWhileLastSeenStaysFresh(t *te
if system.StatusExplanation.Summary == "" {
t.Fatal("expected grouped monitored system status explanation summary")
}
+ if system.StatusExplanation.Summary != "Pulse most recently heard from Docker for tower.local at 2026-03-23T11:59:50Z, but Agent data for tower.local is stale (last reported 2026-03-23T11:55:00Z), so this monitored system is warning." {
+ t.Fatalf("unexpected grouped monitored system summary: %q", system.StatusExplanation.Summary)
+ }
if len(system.StatusExplanation.Reasons) != 1 {
t.Fatalf("expected one stale grouped-source reason, got %+v", system.StatusExplanation.Reasons)
}