mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user