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.

Expose Docker health-check dependencies to Patrol

rcourtmand08ca46194d4
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 02b77e7217..9b584e3fc9 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -84,6 +84,12 @@ Docker / Podman report sizing is a two-dimensional transport contract:
decoded JSON byte ceilings, derives the 80% early-warning boundaries, and
generates the operator-facing limit description consumed by server ingress
and every supported `pulse-agent` release target built from this source.
+Docker health-check dependency evidence follows the same report boundary.
+The agent may derive a bounded list of normalized URL hostnames from the
+runtime-authored health-check test, but raw health-check commands, URL paths,
+queries, credentials, and environment expansion must never enter the report.
+Those secret-free targets are observational metadata only: they do not grant
+command authority or change container lifecycle admission.
An agent's lifecycle operations are scoped to that agent. Installing,
diff --git a/docs/release-control/v6/internal/subsystems/ai-runtime.md b/docs/release-control/v6/internal/subsystems/ai-runtime.md
index ceb32486e4..bebc719ac2 100644
--- a/docs/release-control/v6/internal/subsystems/ai-runtime.md
+++ b/docs/release-control/v6/internal/subsystems/ai-runtime.md
@@ -4633,6 +4633,13 @@ so a model can distinguish complete topology evidence from a bounded preview
and continue with a larger bound or paginated list instead of inventing a root
cause from missing resources.
+Docker container topology and resource context must also expose the canonical
+resource's bounded `healthcheck_targets` hostname list when present. Patrol may
+use a target that matches another exact container name to test a causal
+dependency chain, but the target remains untrusted observational evidence and
+never grants tool or action authority. The AI boundary must not receive the raw
+health-check command, URL path, query, credentials, or environment expansion.
+
When the model runs tools but returns no final narrative, the deterministic
fallback summary (`buildAutomaticFallbackSummary` in
`internal/ai/chat/agentic_final.go`) must read as a clean operator message, not a
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index aabbb29de4..ecfe4daf8a 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -4812,7 +4812,10 @@ copy/export consumers: they may expose bounded Pulse-authored or
Pulse-observed runtime/discovery, topology, safety, policy, and recent-change
facts, but must not expose raw command output, provider config, environment
values, unbounded metadata maps, bind-mount paths, label values, or secret-like
-capability parameters.
+capability parameters. Docker runtime sections may expose normalized hostnames
+derived from health-check URL targets as bounded topology facts. They must apply
+the resource policy to each hostname independently and must never carry the raw
+health-check command, URL path, query, user information, or environment values.
The shape is intentionally narrower than the full internal types
so agents see a stable agent-paradigm contract, decoupled from
internal type evolution.
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 0b7fa75f0b..a9ee5a9627 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -607,6 +607,11 @@ cleanup so readers cannot retain orphaned runtime or alert projections.
collector must set it to the exact Docker inspect boolean even when false;
report ingest and model conversion must clone and preserve the pointer so
concurrent state replacement cannot alter previously accepted evidence.
+ Container health-check dependency targets must likewise come from the
+ inspected runtime configuration, but monitoring accepts only the agent's
+ bounded, normalized URL hostname projection. Ingest must preserve an
+ independent copy through `models.DockerContainer`; raw health-check command,
+ path, query, credential, and environment text is outside the report model.
8. Add or change Proxmox Ceph compatibility payload decoding through `pkg/proxmox/ceph.go`
9. Add or change Proxmox ZFS compatibility payload decoding and vdev-role normalization through `pkg/proxmox/zfs.go`
10. Add or change mock chart synthesis, seeded history continuity, or mock-owned
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 7be8d130a5..8d7f45cb08 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -1477,12 +1477,14 @@ recovery scope, or a storage/recovery-owned secret source.
only; they must not reinterpret it as backup freshness, recovery
point recency, or protection cadence.
Docker / Podman `DockerData` container lifecycle, Podman metadata, and
- cumulative block I/O totals, including nullable runtime-authored OOM state,
- remain unified-resource runtime context.
+ cumulative block I/O totals, including nullable runtime-authored OOM state
+ and secret-free health-check target hostnames, remain unified-resource
+ runtime context.
Storage and recovery may use those fields only as workload description
when linking to an owning runtime/platform page; they must not reinterpret
- container block I/O totals as backup throughput, recovery-point evidence,
- protection cadence, or storage-health ownership.
+ health-check targets as protection topology, or container block I/O totals
+ as backup throughput, recovery-point evidence, protection cadence, or
+ storage-health ownership.
30. Keep VMware placement, cluster service state, guest-detail, VM snapshot-tree, VM virtual-hardware configuration, VMware Tools, VM hardware Ethernet, VM hardware disk, and network enrichment descriptive on that same shared unified-resource contract. When `internal/vmware/provider.go`, `internal/unifiedresources/types.go`, and `frontend-modern/src/hooks/useUnifiedResources.ts` project datacenter, cluster, `vmware.clusterHaEnabled`, `vmware.clusterDrsEnabled`, folder, runtime-host, datastore-attachment, guest-hostname, guest-IP, `vmware.currentSnapshotId`, `vmware.snapshotTree`, snapshot creation/state/quiesce/current markers, child snapshot metadata, `vmware.hardware`, virtual hardware version, hardware upgrade policy/version/status/error, boot type/order/retry/setup-mode flags, CPU cores-per-socket and hot-add/remove flags, memory hot-add settings, `vmware.tools`, Tools run state, version status, version number/string, install type, upgrade policy, auto-update support, install-attempt count, guest reboot requests, `vmware.networkAdapters`, adapter MAC address/type, backing network id/name, backing type, connection state, start-connected / guest-control flags, `vmware.virtualDisks`, virtual disk label/type, IDE/SCSI/SATA/NVMe placement, VMDK path, backing type, datastore name, capacity, `vmware.networkType`, `vmware.networkHostNames`, `vmware.networkVmNames`, or `vmware.tags` onto canonical VMware `agent` / `vm` / `storage` / `network` resources, storage and recovery may use that detail for labeling, navigation, and VM investigation context only; they must not promote those topology, cluster-service, guest, snapshot-tree, virtual-hardware, VMware Tools, vNIC, virtual disk, tag, or network fields into recovery ownership, restore targeting, protection grouping, compliance scoring, or a VMware-local recovery taxonomy without a separately governed slice.
`vmware.tags` is the sharpest case of that boundary, because vCenter tag
vocabularies routinely read like backup policy — an operator-authored
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 86c83cc188..ce7a108939 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -697,6 +697,12 @@ code 137 into a positive classification; typed Docker views must return an
independent copy of that value. Frontend detail summaries and
Docker page search consume those backend-authored fields before falling back to
legacy labels.
+`DockerData.HealthcheckTargets` is the canonical secret-free dependency hint
+for container health checks. The adapter, clone, and typed Docker container
+view must preserve independent copies, while consumers treat each hostname as
+untrusted observational topology evidence rather than command, discovery, or
+action authority. Raw health-check command text never belongs in the unified
+resource contract.
Docker host duplicate-identity evidence is monitoring-authored and rides
`DockerData.IdentityConflict` unchanged: the adapter, resource clone, and
typed `DockerHostView` accessor must each hand out an independent copy so
diff --git a/internal/agentcontext/resource_context_sections.go b/internal/agentcontext/resource_context_sections.go
index 2d3e028be5..9b1ff1f00c 100644
--- a/internal/agentcontext/resource_context_sections.go
+++ b/internal/agentcontext/resource_context_sections.go
@@ -563,6 +563,7 @@ func addDockerFacts(facts *[]Fact, resource unified.Resource, observedAt *time.T
addAgentContextCountFact(facts, "Images", resource.Docker.ImageCount, agentContextSourceUnifiedResource, agentContextTrustRuntimeObserved, observedAt)
addAgentContextFact(facts, "Container state", resource.Docker.ContainerState, agentContextSourceUnifiedResource, agentContextTrustRuntimeObserved, observedAt)
addAgentContextFact(facts, "Container health", resource.Docker.Health, agentContextSourceUnifiedResource, agentContextTrustRuntimeObserved, observedAt)
+ addAgentContextFact(facts, "Health-check targets", formatDockerHealthcheckTargets(resource.Docker.HealthcheckTargets, policy), agentContextSourceUnifiedResource, agentContextTrustDiscovered, observedAt)
if resource.Docker.RestartCount > 0 {
addAgentContextFact(facts, "Restart count", fmt.Sprintf("%d", resource.Docker.RestartCount), agentContextSourceUnifiedResource, agentContextTrustRuntimeObserved, observedAt)
}
@@ -580,6 +581,20 @@ func addDockerFacts(facts *[]Fact, resource unified.Resource, observedAt *time.T
}
}
+func formatDockerHealthcheckTargets(targets []string, policy *unified.ResourcePolicy) string {
+ if len(targets) == 0 {
+ return ""
+ }
+ formatted := make([]string, 0, len(targets))
+ for _, target := range targets {
+ value := unified.ResourcePolicyRedactedValue(target, policy, unified.ResourceRedactionHostname, unified.ResourceRedactionAlias)
+ if value != "" {
+ formatted = append(formatted, value)
+ }
+ }
+ return strings.Join(formatted, ", ")
+}
+
func addKubernetesFacts(facts *[]Fact, resource unified.Resource, observedAt *time.Time) {
if resource.Kubernetes == nil {
return
diff --git a/internal/agentcontext/resource_context_sections_test.go b/internal/agentcontext/resource_context_sections_test.go
index c884c9759b..f7093e308f 100644
--- a/internal/agentcontext/resource_context_sections_test.go
+++ b/internal/agentcontext/resource_context_sections_test.go
@@ -52,8 +52,9 @@ func TestBuildResourceContextSectionsAppliesRedactionTrustAndFreshness(t *testin
},
}
resource.Docker = &unified.DockerData{
- Image: "registry.internal/finance-db:latest",
- ContainerState: "running",
+ Image: "registry.internal/finance-db:latest",
+ ContainerState: "running",
+ HealthcheckTargets: []string{"finance-db.internal"},
Ports: []unified.DockerPortMeta{
{PublicPort: 8123, PrivatePort: 8123, Protocol: "tcp"},
},
@@ -90,6 +91,11 @@ func TestBuildResourceContextSectionsAppliesRedactionTrustAndFreshness(t *testin
PendingApprovalCount: 1,
RecentActionCount: 3,
})
+ docker := requireSection(t, sections, "runtime")
+ healthcheckTargets := requireFact(t, docker, "Health-check targets")
+ if !healthcheckTargets.Redacted || healthcheckTargets.Value != unified.ResourcePolicyRedactedLabel {
+ t.Fatalf("health-check targets fact = %#v, want policy-redacted hostname evidence", healthcheckTargets)
+ }
identity := requireSection(t, sections, "identity")
if identity.Source != agentContextSourceUnifiedResource || identity.TrustTier != agentContextTrustPulseAuthored {
diff --git a/internal/ai/tools/data_types.go b/internal/ai/tools/data_types.go
index 88b947ef65..3458945ee6 100644
--- a/internal/ai/tools/data_types.go
+++ b/internal/ai/tools/data_types.go
@@ -317,11 +317,12 @@ func (s DockerHostSummary) NormalizeCollections() DockerHostSummary {
// DockerContainerSummary is a summarized Docker container
type DockerContainerSummary struct {
GovernedResourceMetadata
- ID string `json:"id"`
- Name string `json:"name"`
- State string `json:"state"`
- Image string `json:"image"`
- Health string `json:"health,omitempty"`
+ ID string `json:"id"`
+ Name string `json:"name"`
+ State string `json:"state"`
+ Image string `json:"image"`
+ Health string `json:"health,omitempty"`
+ HealthcheckTargets []string `json:"healthcheck_targets,omitempty"`
}
// AppContainerSummary is a summarized canonical app container for list responses.
diff --git a/internal/ai/tools/tools_query.go b/internal/ai/tools/tools_query.go
index 3bec2b20d3..9e49f2ae6a 100644
--- a/internal/ai/tools/tools_query.go
+++ b/internal/ai/tools/tools_query.go
@@ -4446,6 +4446,7 @@ func BuildTopologyResponseFromReadState(rs unifiedresources.ReadState, options T
State: state,
Image: container.Image(),
Health: container.Health(),
+ HealthcheckTargets: container.HealthcheckTargets(),
})
}
}
diff --git a/internal/ai/tools/tools_query_test.go b/internal/ai/tools/tools_query_test.go
index b199aba296..df960d0e06 100644
--- a/internal/ai/tools/tools_query_test.go
+++ b/internal/ai/tools/tools_query_test.go
@@ -518,7 +518,7 @@ func TestExecuteListInfrastructureAndTopology(t *testing.T) {
Hostname: "h1",
DisplayName: "Host 1",
Containers: []models.DockerContainer{
- {ID: "c1", Name: "nginx", State: "running", Image: "nginx"},
+ {ID: "c1", Name: "nginx", State: "running", Image: "nginx", HealthcheckTargets: []string{"database.internal"}},
},
},
},
@@ -561,6 +561,11 @@ func TestExecuteListInfrastructureAndTopology(t *testing.T) {
if topology.Summary.TotalVMs != 1 || len(topology.Proxmox.Nodes) == 0 {
t.Fatalf("unexpected topology: %+v", topology)
}
+ if len(topology.Docker.Hosts) != 1 || len(topology.Docker.Hosts[0].Containers) != 1 ||
+ len(topology.Docker.Hosts[0].Containers[0].HealthcheckTargets) != 1 ||
+ topology.Docker.Hosts[0].Containers[0].HealthcheckTargets[0] != "database.internal" {
+ t.Fatalf("Docker topology lost health-check dependency targets: %+v", topology.Docker)
+ }
}
func TestExecuteGetTopologySummaryOnly(t *testing.T) {
diff --git a/internal/dockeragent/agent_collect_test.go b/internal/dockeragent/agent_collect_test.go
index d15672f554..b84e9f8511 100644
--- a/internal/dockeragent/agent_collect_test.go
+++ b/internal/dockeragent/agent_collect_test.go
@@ -37,6 +37,32 @@ func TestBuildHostSecurityInfoAuthorizationPlugins(t *testing.T) {
}
}
+func TestExtractHealthcheckTargetsKeepsOnlyNormalizedURLHosts(t *testing.T) {
+ targets := extractHealthcheckTargets([]string{
+ "CMD-SHELL",
+ "wget -qO- 'http://Dependency-Service:8080/health?token=private' && curl https://user:[email protected]/status",
+ "curl http://dependency-service:9090/duplicate",
+ "curl 'http://[2001:db8::1]:8080/ready'",
+ "printf 'not-a-url secret=value'",
+ })
+
+ want := []string{"dependency-service", "api.internal.example", "2001:db8::1"}
+ if len(targets) != len(want) {
+ t.Fatalf("health-check targets = %#v, want %#v", targets, want)
+ }
+ for i := range want {
+ if targets[i] != want[i] {
+ t.Fatalf("health-check target %d = %q, want %q", i, targets[i], want[i])
+ }
+ }
+ joined := strings.Join(targets, " ")
+ for _, forbidden := range []string{"token", "private", "user", "password", "/health", "/status"} {
+ if strings.Contains(joined, forbidden) {
+ t.Fatalf("health-check targets leaked %q: %q", forbidden, joined)
+ }
+ }
+}
+
func TestCollectDockerNativeInventory(t *testing.T) {
createdAt := time.Date(2026, 5, 24, 8, 0, 0, 0, time.UTC)
agent := &Agent{
diff --git a/internal/dockeragent/collect.go b/internal/dockeragent/collect.go
index 489d4a18f4..b29ab53b98 100644
--- a/internal/dockeragent/collect.go
+++ b/internal/dockeragent/collect.go
@@ -9,6 +9,8 @@ import (
"math"
"math/big"
"net/netip"
+ "net/url"
+ "regexp"
"strconv"
"strings"
"time"
@@ -567,6 +569,10 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
if inspect.State.Health != nil {
health = string(inspect.State.Health.Status)
}
+ healthcheckTargets := []string(nil)
+ if inspect.Config != nil && inspect.Config.Healthcheck != nil {
+ healthcheckTargets = extractHealthcheckTargets(inspect.Config.Healthcheck.Test)
+ }
ports := make([]agentsdocker.ContainerPort, len(summary.Ports))
for i, port := range summary.Ports {
@@ -641,6 +647,7 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
State: string(summary.State),
Status: summary.Status,
Health: health,
+ HealthcheckTargets: healthcheckTargets,
CPUPercent: cpuPercent,
MemoryUsageBytes: memUsage,
MemoryLimitBytes: memLimit,
@@ -732,6 +739,50 @@ func (a *Agent) collectContainer(ctx context.Context, summary containertypes.Sum
return container, nil
}
+var (
+ healthcheckURLPattern = regexp.MustCompile(`(?i)https?://[^\s'"<>]+`)
+ healthcheckTargetPattern = regexp.MustCompile(`(?i)^[a-z0-9][a-z0-9._-]{0,252}$`)
+)
+
+// extractHealthcheckTargets derives only secret-free URL hostnames from a
+// container health check. Raw health-check command text can contain paths,
+// query strings, credentials, or environment expansion and must never cross
+// the agent reporting boundary.
+func extractHealthcheckTargets(test []string) []string {
+ const maxTargets = 16
+ seen := make(map[string]struct{})
+ targets := make([]string, 0)
+ for _, part := range test {
+ for _, candidate := range healthcheckURLPattern.FindAllString(part, -1) {
+ if len(candidate) > 2048 {
+ continue
+ }
+ parsed, err := url.Parse(candidate)
+ if err != nil {
+ continue
+ }
+ target := strings.ToLower(strings.TrimSpace(parsed.Hostname()))
+ if address, err := netip.ParseAddr(target); err == nil {
+ target = address.String()
+ } else if !healthcheckTargetPattern.MatchString(target) {
+ continue
+ }
+ if _, exists := seen[target]; exists {
+ continue
+ }
+ seen[target] = struct{}{}
+ targets = append(targets, target)
+ if len(targets) == maxTargets {
+ return targets
+ }
+ }
+ }
+ if len(targets) == 0 {
+ return nil
+ }
+ return targets
+}
+
// getImageRepoDigest retrieves the RepoDigest for an image and its platform details.
// It returns the digest, architecture, OS, and variant.
func (a *Agent) getImageRepoDigest(ctx context.Context, imageID, imageName string) (string, string, string, string) {
diff --git a/internal/models/deepcopy.go b/internal/models/deepcopy.go
index 55a4a595ea..09445f761c 100644
--- a/internal/models/deepcopy.go
+++ b/internal/models/deepcopy.go
@@ -480,6 +480,7 @@ func cloneDockerContainerUpdateStatus(src *DockerContainerUpdateStatus) *DockerC
func cloneDockerContainer(src DockerContainer) DockerContainer {
dest := src
+ dest.HealthcheckTargets = append([]string(nil), src.HealthcheckTargets...)
dest.OOMKilled = cloneBoolPtr(src.OOMKilled)
dest.StartedAt = cloneTimePtr(src.StartedAt)
dest.FinishedAt = cloneTimePtr(src.FinishedAt)
diff --git a/internal/models/deepcopy_test.go b/internal/models/deepcopy_test.go
index c290030c8b..1e7c5c17f2 100644
--- a/internal/models/deepcopy_test.go
+++ b/internal/models/deepcopy_test.go
@@ -68,7 +68,11 @@ func TestCloneHostAndZFSPoolIsolateZFSDatasets(t *testing.T) {
func TestCloneDockerContainer_PreservesIndependentOOMEvidence(t *testing.T) {
oomKilled := false
- src := DockerContainer{ID: "container-1", OOMKilled: &oomKilled}
+ src := DockerContainer{
+ ID: "container-1",
+ HealthcheckTargets: []string{"dependency-service"},
+ OOMKilled: &oomKilled,
+ }
got := cloneDockerContainer(src)
if got.OOMKilled == nil || *got.OOMKilled {
@@ -78,6 +82,10 @@ func TestCloneDockerContainer_PreservesIndependentOOMEvidence(t *testing.T) {
if *got.OOMKilled {
t.Fatal("cloned Docker container must own its OOM evidence value")
}
+ got.HealthcheckTargets[0] = "mutated"
+ if src.HealthcheckTargets[0] != "dependency-service" {
+ t.Fatal("cloned Docker container must own its health-check targets")
+ }
}
func TestCloneDockerHost_PreservesIndependentIdentityConflict(t *testing.T) {
diff --git a/internal/models/models.go b/internal/models/models.go
index ca7926749d..b40918dd88 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -1104,6 +1104,7 @@ type DockerContainer struct {
State string `json:"state"`
Status string `json:"status"`
Health string `json:"health,omitempty"`
+ HealthcheckTargets []string `json:"healthcheckTargets,omitempty"`
CPUPercent float64 `json:"cpuPercent"`
CPUCapacityPercent float64 `json:"cpuCapacityPercent,omitempty"`
MemoryUsage int64 `json:"memoryUsageBytes"`
@@ -1132,6 +1133,9 @@ type DockerContainer struct {
}
func (c DockerContainer) NormalizeCollections() DockerContainer {
+ if c.HealthcheckTargets == nil {
+ c.HealthcheckTargets = []string{}
+ }
if c.Ports == nil {
c.Ports = []DockerContainerPort{}
}
diff --git a/internal/monitoring/monitor_agents.go b/internal/monitoring/monitor_agents.go
index 9887cb89cf..665851b36e 100644
--- a/internal/monitoring/monitor_agents.go
+++ b/internal/monitoring/monitor_agents.go
@@ -1881,26 +1881,27 @@ func (m *Monitor) ApplyDockerReport(report agentsdocker.Report, tokenRecord *con
containers := make([]models.DockerContainer, 0, len(report.Containers))
for _, payload := range report.Containers {
container := models.DockerContainer{
- ID: payload.ID,
- Name: payload.Name,
- Image: payload.Image,
- ImageDigest: payload.ImageDigest,
- State: payload.State,
- Status: payload.Status,
- Health: payload.Health,
- CPUPercent: safeFloat(payload.CPUPercent),
- MemoryUsage: payload.MemoryUsageBytes,
- MemoryLimit: payload.MemoryLimitBytes,
- MemoryPercent: safeFloat(payload.MemoryPercent),
- UptimeSeconds: payload.UptimeSeconds,
- RestartCount: payload.RestartCount,
- ExitCode: payload.ExitCode,
- OOMKilled: cloneReportBoolPtr(payload.OOMKilled),
- CreatedAt: payload.CreatedAt,
- StartedAt: payload.StartedAt,
- FinishedAt: payload.FinishedAt,
- NetworkRXBytes: payload.NetworkRXBytes,
- NetworkTXBytes: payload.NetworkTXBytes,
+ ID: payload.ID,
+ Name: payload.Name,
+ Image: payload.Image,
+ ImageDigest: payload.ImageDigest,
+ State: payload.State,
+ Status: payload.Status,
+ Health: payload.Health,
+ HealthcheckTargets: append([]string(nil), payload.HealthcheckTargets...),
+ CPUPercent: safeFloat(payload.CPUPercent),
+ MemoryUsage: payload.MemoryUsageBytes,
+ MemoryLimit: payload.MemoryLimitBytes,
+ MemoryPercent: safeFloat(payload.MemoryPercent),
+ UptimeSeconds: payload.UptimeSeconds,
+ RestartCount: payload.RestartCount,
+ ExitCode: payload.ExitCode,
+ OOMKilled: cloneReportBoolPtr(payload.OOMKilled),
+ CreatedAt: payload.CreatedAt,
+ StartedAt: payload.StartedAt,
+ FinishedAt: payload.FinishedAt,
+ NetworkRXBytes: payload.NetworkRXBytes,
+ NetworkTXBytes: payload.NetworkTXBytes,
}
container.CPUCapacityPercent = models.DockerContainerCPUCapacityPercent(container, report.Host.TotalCPU)
diff --git a/internal/monitoring/monitor_docker_test.go b/internal/monitoring/monitor_docker_test.go
index 8b947d2bd7..c76dc9bb4e 100644
--- a/internal/monitoring/monitor_docker_test.go
+++ b/internal/monitoring/monitor_docker_test.go
@@ -278,6 +278,7 @@ func TestApplyDockerReportIncludesContainerDiskDetails(t *testing.T) {
{
ID: "ctr-1",
Name: "app",
+ HealthcheckTargets: []string{"dependency-service"},
OOMKilled: &oomKilled,
WritableLayerBytes: 512 * 1024 * 1024,
RootFilesystemBytes: 2 * 1024 * 1024 * 1024,
@@ -320,6 +321,10 @@ func TestApplyDockerReportIncludesContainerDiskDetails(t *testing.T) {
if *container.OOMKilled {
t.Fatal("expected monitoring state to own an independent OOM evidence value")
}
+ report.Containers[0].HealthcheckTargets[0] = "mutated"
+ if container.HealthcheckTargets[0] != "dependency-service" {
+ t.Fatal("expected monitoring state to own an independent health-check target slice")
+ }
if container.WritableLayerBytes != 512*1024*1024 {
t.Fatalf("expected writable layer bytes to match, got %d", container.WritableLayerBytes)
}
diff --git a/internal/monitoring/monitor_host_agents_test.go b/internal/monitoring/monitor_host_agents_test.go
index eacac07a18..0bbb3819c7 100644
--- a/internal/monitoring/monitor_host_agents_test.go
+++ b/internal/monitoring/monitor_host_agents_test.go
@@ -651,9 +651,10 @@ func TestApplyDockerReportRefreshesUnifiedReadStateWithoutBroadcast(t *testing.T
TotalMemoryBytes: 8 << 30,
},
Containers: []agentsdocker.Container{{
- ID: "headless-container-id",
- Name: "headless-canary-container",
- State: "running",
+ ID: "headless-container-id",
+ Name: "headless-canary-container",
+ State: "running",
+ HealthcheckTargets: []string{"dependency-service"},
}},
Timestamp: time.Now().UTC(),
}, nil)
@@ -676,6 +677,10 @@ func TestApplyDockerReportRefreshesUnifiedReadStateWithoutBroadcast(t *testing.T
for _, container := range adapter.DockerContainers() {
if container != nil && container.Name() == "headless-canary-container" {
foundContainer = true
+ targets := container.HealthcheckTargets()
+ if len(targets) != 1 || targets[0] != "dependency-service" {
+ t.Fatalf("canonical health-check targets = %v, want dependency-service", targets)
+ }
break
}
}
diff --git a/internal/unifiedresources/adapters.go b/internal/unifiedresources/adapters.go
index 68c969ec72..1af718cebe 100644
--- a/internal/unifiedresources/adapters.go
+++ b/internal/unifiedresources/adapters.go
@@ -2352,6 +2352,7 @@ func resourceFromDockerContainer(ct models.DockerContainer, host models.DockerHo
UptimeSeconds: ct.UptimeSeconds,
ContainerState: ct.State,
Health: ct.Health,
+ HealthcheckTargets: cloneStringSlice(ct.HealthcheckTargets),
RestartCount: ct.RestartCount,
ExitCode: ct.ExitCode,
OOMKilled: cloneBoolPtr(ct.OOMKilled),
diff --git a/internal/unifiedresources/clone.go b/internal/unifiedresources/clone.go
index 620b832f10..d94372cf64 100644
--- a/internal/unifiedresources/clone.go
+++ b/internal/unifiedresources/clone.go
@@ -308,6 +308,7 @@ func cloneDockerData(in *DockerData) *DockerData {
out.VolumesUsage = cloneDockerStorageUsageMeta(in.VolumesUsage)
out.BuildCacheUsage = cloneDockerStorageUsageMeta(in.BuildCacheUsage)
out.Ports = cloneDockerPortMetaSlice(in.Ports)
+ out.HealthcheckTargets = cloneStringSlice(in.HealthcheckTargets)
out.Labels = cloneStringMap(in.Labels)
out.EngineLabels = cloneStringMap(in.EngineLabels)
out.Networks = cloneDockerNetworkMetaSlice(in.Networks)
diff --git a/internal/unifiedresources/clone_test.go b/internal/unifiedresources/clone_test.go
index d1df6232ea..4a096ad6ec 100644
--- a/internal/unifiedresources/clone_test.go
+++ b/internal/unifiedresources/clone_test.go
@@ -592,8 +592,9 @@ func TestCloneDockerData_Nil(t *testing.T) {
func TestCloneDockerData_LabelsAndPortsIsolation(t *testing.T) {
original := &DockerData{
- ContainerID: "abc123",
- Labels: map[string]string{"env": "prod"},
+ ContainerID: "abc123",
+ HealthcheckTargets: []string{"database.internal"},
+ Labels: map[string]string{"env": "prod"},
Ports: []DockerPortMeta{
{PrivatePort: 8080, Protocol: "tcp"},
},
@@ -609,6 +610,11 @@ func TestCloneDockerData_LabelsAndPortsIsolation(t *testing.T) {
if original.Ports[0].PublicPort == 9999 {
t.Error("mutating cloned Ports should not affect original")
}
+
+ cloned.HealthcheckTargets[0] = "changed.internal"
+ if original.HealthcheckTargets[0] != "database.internal" {
+ t.Error("mutating cloned HealthcheckTargets should not affect original")
+ }
}
// --- primitive clone helpers ---
diff --git a/internal/unifiedresources/types.go b/internal/unifiedresources/types.go
index 6a93d43414..7e4a358259 100644
--- a/internal/unifiedresources/types.go
+++ b/internal/unifiedresources/types.go
@@ -1126,6 +1126,7 @@ type DockerData struct {
// Container-specific fields (populated when Resource.Type == ResourceTypeAppContainer)
ContainerState string `json:"containerState,omitempty"`
Health string `json:"health,omitempty"`
+ HealthcheckTargets []string `json:"healthcheckTargets,omitempty"`
RestartCount int `json:"restartCount,omitempty"`
ExitCode int `json:"exitCode,omitempty"`
OOMKilled *bool `json:"oomKilled,omitempty"`
diff --git a/internal/unifiedresources/views.go b/internal/unifiedresources/views.go
index 4368e7b3de..ff58e254e3 100644
--- a/internal/unifiedresources/views.go
+++ b/internal/unifiedresources/views.go
@@ -3901,6 +3901,13 @@ func (v DockerContainerView) Health() string {
return v.r.Docker.Health
}
+func (v DockerContainerView) HealthcheckTargets() []string {
+ if v.r == nil || v.r.Docker == nil {
+ return nil
+ }
+ return append([]string(nil), v.r.Docker.HealthcheckTargets...)
+}
+
func (v DockerContainerView) RestartCount() int {
if v.r == nil || v.r.Docker == nil {
return 0
diff --git a/internal/unifiedresources/views_test.go b/internal/unifiedresources/views_test.go
index d33de3da94..cc6c6465d5 100644
--- a/internal/unifiedresources/views_test.go
+++ b/internal/unifiedresources/views_test.go
@@ -1291,10 +1291,11 @@ func TestView_DockerContainerViewMetricsTargetAccessor(t *testing.T) {
ResourceID: "nextcloud-web-1",
},
Docker: &DockerData{
- ContainerID: "nextcloud",
- Image: "docker.io/library/nextcloud:29.0.7",
- ContainerState: "running",
- OOMKilled: &oomKilled,
+ ContainerID: "nextcloud",
+ Image: "docker.io/library/nextcloud:29.0.7",
+ ContainerState: "running",
+ HealthcheckTargets: []string{"postgres.internal"},
+ OOMKilled: &oomKilled,
},
}
@@ -1324,6 +1325,15 @@ func TestView_DockerContainerViewMetricsTargetAccessor(t *testing.T) {
if got := v.OOMKilled(); got == nil || *got {
t.Fatalf("expected cloned OOM evidence, got %v", got)
}
+
+ targets := v.HealthcheckTargets()
+ if len(targets) != 1 || targets[0] != "postgres.internal" {
+ t.Fatalf("health-check targets = %v, want postgres.internal", targets)
+ }
+ targets[0] = "mutated"
+ if got := v.HealthcheckTargets(); len(got) != 1 || got[0] != "postgres.internal" {
+ t.Fatalf("expected cloned health-check targets, got %v", got)
+ }
}
func TestView_PBSAndPMGInstanceViewAccessors(t *testing.T) {
diff --git a/pkg/agents/docker/report.go b/pkg/agents/docker/report.go
index 1e49b732a8..6c4ff60030 100644
--- a/pkg/agents/docker/report.go
+++ b/pkg/agents/docker/report.go
@@ -73,6 +73,7 @@ type Container struct {
State string `json:"state"`
Status string `json:"status"`
Health string `json:"health,omitempty"`
+ HealthcheckTargets []string `json:"healthcheckTargets,omitempty"`
CPUPercent float64 `json:"cpuPercent"`
MemoryUsageBytes int64 `json:"memoryUsageBytes"`
MemoryLimitBytes int64 `json:"memoryLimitBytes"`