Skip to content

Commit

Permalink
Fix loop in filesystemn reporting and debug statement in fsstat (#33646)
Browse files Browse the repository at this point in the history
* fix loop in filesystem and debug loop in fsstat

* add changelog

* Update CHANGELOG.next.asciidoc

Co-authored-by: Craig MacKenzie <craig.mackenzie@elastic.co>

Co-authored-by: Craig MacKenzie <craig.mackenzie@elastic.co>
  • Loading branch information
fearful-symmetry and cmacknz committed Nov 10, 2022
1 parent 6e14d08 commit a56c4f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down
7 changes: 4 additions & 3 deletions metricbeat/module/system/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/fsstat/fsstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a56c4f7

Please sign in to comment.