fix(agent): apply --disk-exclude to Docker agent disk metrics (#1237)

The Docker agent was not passing the disk exclusion list to
hostmetricsCollect(), so excluded mounts appeared in the Docker tab
disk totals. Also add server-side fsfilters filtering to Docker
report processing for parity with the host agent path.
This commit is contained in:
rcourtman
2026-02-10 16:59:35 +00:00
parent dea68a7521
commit 26776b2075
4 changed files with 8 additions and 1 deletions

View File

@@ -306,6 +306,7 @@ func run(ctx context.Context, args []string, getenv func(string) string) error {
IncludeServices: true,
IncludeTasks: true,
CollectDiskMetrics: false,
DiskExclude: cfg.DiskExclude,
}
dockerAgent, err = newDockerAgent(dockerCfg)

View File

@@ -50,6 +50,7 @@ type Config struct {
IncludeTasks bool
IncludeContainers bool
CollectDiskMetrics bool
DiskExclude []string // Mount points or path prefixes to exclude from disk monitoring
LogLevel zerolog.Level
Logger *zerolog.Logger
}

View File

@@ -91,7 +91,7 @@ func (a *Agent) buildReport(ctx context.Context) (agentsdocker.Report, error) {
uptime := readSystemUptime()
metricsCtx, metricsCancel := context.WithTimeout(ctx, 10*time.Second)
snapshot, err := hostmetricsCollect(metricsCtx, nil)
snapshot, err := hostmetricsCollect(metricsCtx, a.cfg.DiskExclude)
metricsCancel()
if err != nil {
return agentsdocker.Report{}, fmt.Errorf("collect host metrics: %w", err)

View File

@@ -2187,6 +2187,11 @@ func (m *Monitor) ApplyDockerReport(report agentsdocker.Report, tokenRecord *con
disks := make([]models.Disk, 0, len(report.Host.Disks))
for _, disk := range report.Host.Disks {
// Filter virtual/system filesystems (same as ApplyHostReport) to avoid
// inflated disk totals from tmpfs, overlayfs, etc.
if shouldSkip, _ := fsfilters.ShouldSkipFilesystem(disk.Type, disk.Mountpoint, uint64(disk.TotalBytes), uint64(disk.UsedBytes)); shouldSkip {
continue
}
disks = append(disks, models.Disk{
Total: disk.TotalBytes,
Used: disk.UsedBytes,