From a56c4f784c25676ea2184e58686555bbcd1f538f Mon Sep 17 00:00:00 2001 From: Alex K <8418476+fearful-symmetry@users.noreply.github.com> Date: Thu, 10 Nov 2022 13:32:37 -0800 Subject: [PATCH] Fix loop in filesystemn reporting and debug statement in fsstat (#33646) * fix loop in filesystem and debug loop in fsstat * add changelog * Update CHANGELOG.next.asciidoc Co-authored-by: Craig MacKenzie Co-authored-by: Craig MacKenzie --- CHANGELOG.next.asciidoc | 2 ++ metricbeat/module/system/filesystem/filesystem.go | 7 ++++--- metricbeat/module/system/fsstat/fsstat.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 583fa044117..1f5127cda30 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -92,6 +92,8 @@ https://github.com/elastic/beats/compare/v8.2.0\...main[Check the HEAD diff] - Fix logstash cgroup mappings {pull}33131[33131] - Remove unused `elasticsearch.node_stats.indices.bulk.avg_time.bytes` mapping {pull}33263[33263] - Add tags to events based on parsed identifier. {pull}33472[33472] +- Skip over unsupported filesystems in the system.filesystem metricset instead of failing immediately. Fix debug statement in system.fsstat metricset. {pull}33646[33646] + *Packetbeat* diff --git a/metricbeat/module/system/filesystem/filesystem.go b/metricbeat/module/system/filesystem/filesystem.go index 6db85a805d1..60a1c4a5bf7 100644 --- a/metricbeat/module/system/filesystem/filesystem.go +++ b/metricbeat/module/system/filesystem/filesystem.go @@ -79,7 +79,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { // Fetch fetches filesystem metrics for all mounted filesystems and returns // an event for each mount point. func (m *MetricSet) Fetch(r mb.ReporterV2) error { - fsList, err := fs.GetFilesystems(m.sys, fs.BuildFilterWithList(m.config.IgnoreTypes)) if err != nil { return fmt.Errorf("error fetching filesystem list: %w", err) @@ -88,12 +87,14 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error { for _, fs := range fsList { err := fs.GetUsage() if err != nil { - return fmt.Errorf("error getting filesystem usage for %s: %w", fs.Directory, err) + m.Logger().Errorf("error getting filesystem usage for %s: %s", fs.Directory, err) + continue } out := mapstr.M{} err = typeconv.Convert(&out, fs) if err != nil { - return fmt.Errorf("error converting event %s: %w", fs.Device, err) + m.Logger().Errorf("error converting filesystem event for %s: %s", fs.Device, err) + continue } event := mb.Event{ diff --git a/metricbeat/module/system/fsstat/fsstat.go b/metricbeat/module/system/fsstat/fsstat.go index 8e11a3f6f41..ddf3be6142c 100644 --- a/metricbeat/module/system/fsstat/fsstat.go +++ b/metricbeat/module/system/fsstat/fsstat.go @@ -84,7 +84,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error { m.Logger().Debugf("error fetching filesystem stats for '%s': %v", fs.Directory, err) continue } - m.Logger().Debugf("filesystem: %s total=%d, used=%d, free=%d", fs.Directory, fs.Total, fs.Used.Bytes.ValueOr(0), fs.Free) + m.Logger().Debugf("filesystem: %s total=%d, used=%d, free=%d", fs.Directory, fs.Total.ValueOr(0), fs.Used.Bytes.ValueOr(0), fs.Free.ValueOr(0)) totalFiles += fs.Files.ValueOr(0) totalSize += fs.Total.ValueOr(0)