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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Add discovery freshness to the local/full context formatter
rcourtmane2f82f8b174e
diff --git a/internal/servicediscovery/formatters.go b/internal/servicediscovery/formatters.goindex 5cb23df927..be4c4f1348 100644--- a/internal/servicediscovery/formatters.go+++ b/internal/servicediscovery/formatters.go@@ -118,6 +118,12 @@ func formatSingleDiscovery(d *ResourceDiscovery) string {sb.WriteString(fmt.Sprintf("- **Type:** %s\n", d.ResourceType))sb.WriteString(fmt.Sprintf("- **Target:** %s\n", firstNonEmpty(d.Hostname, d.TargetID)))+ // Freshness so the model (local/full path) can caveat staleness rather than+ // presenting a cached scan as current — parity with the cloud-safe path.+ if !d.UpdatedAt.IsZero() {+ sb.WriteString(fmt.Sprintf("- **Last Discovered:** %s\n", FormatDiscoveryAge(d)))+ }+if d.ServiceVersion != "" {sb.WriteString(fmt.Sprintf("- **Version:** %s\n", d.ServiceVersion))}diff --git a/internal/servicediscovery/formatters_test.go b/internal/servicediscovery/formatters_test.goindex d8c0ae9c2f..35b421e4d4 100644--- a/internal/servicediscovery/formatters_test.go+++ b/internal/servicediscovery/formatters_test.go@@ -329,3 +329,21 @@ func TestFormatCloudSafeContext(t *testing.T) {t.Errorf("cloud-safe context must report discovery age\n--- output ---\n%s", freshOut)}}++func TestFormatSingleDiscovery_IncludesFreshness(t *testing.T) {+ d := &ResourceDiscovery{+ ID: MakeResourceID(ResourceTypeSystemContainer, "node1", "101"),+ ResourceType: ResourceTypeSystemContainer,+ ServiceName: "Home Assistant",+ }+ // No timestamp -> no freshness line (parity with the cloud-safe path).+ if strings.Contains(formatSingleDiscovery(d), "Last Discovered:") {+ t.Fatalf("expected no freshness line when UpdatedAt is zero")+ }+ // Known timestamp -> the local/full path reports discovery age.+ d.UpdatedAt = time.Now().Add(-3 * time.Hour)+ out := formatSingleDiscovery(d)+ if !strings.Contains(out, "**Last Discovered:** 3 hours ago") {+ t.Fatalf("expected freshness line in single-discovery output, got:\n%s", out)+ }+}