Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Added a new beta `enterprisesearch` module for Elastic Enterprise Search {pull}27549[27549]
- Preliminary AIX support {pull}27954[27954]
- Register additional name for `storage` metricset in the azure module. {pull}28447[28447]
- Update reference to gosigar pacakge for filesystem windows fix. {pull}28909[28909]

*Packetbeat*

Expand Down
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8056,11 +8056,11 @@ Contents of probable licence file $GOMODCACHE/github.com/elastic/go-windows@v1.0

--------------------------------------------------------------------------------
Dependency : github.com/elastic/gosigar
Version: v0.14.1
Version: v0.14.2
Licence type (autodetected): Apache-2.0
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/elastic/gosigar@v0.14.1/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/elastic/gosigar@v0.14.2/LICENSE:

Apache License
Version 2.0, January 2004
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require (
github.com/elastic/go-txfile v0.0.8
github.com/elastic/go-ucfg v0.8.3
github.com/elastic/go-windows v1.0.1
github.com/elastic/gosigar v0.14.1
github.com/elastic/gosigar v0.14.2
github.com/fatih/color v1.9.0
github.com/fearful-symmetry/gorapl v0.0.4
github.com/fsnotify/fsevents v0.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ github.com/elastic/go-ucfg v0.8.3/go.mod h1:iaiY0NBIYeasNgycLyTvhJftQlQEUO2hpF+F
github.com/elastic/go-windows v1.0.0/go.mod h1:TsU0Nrp7/y3+VwE82FoZF8gC/XFg/Elz6CcloAxnPgU=
github.com/elastic/go-windows v1.0.1 h1:AlYZOldA+UJ0/2nBuqWdo90GFCgG9xuyw9SYzGUtJm0=
github.com/elastic/go-windows v1.0.1/go.mod h1:FoVvqWSun28vaDQPbj2Elfc0JahhPB7WQEGa3c814Ss=
github.com/elastic/gosigar v0.14.1 h1:T0aQ7n/n2ZA9W7DmAnj60v+qzqKERdBgJBO1CG2W6rc=
github.com/elastic/gosigar v0.14.1/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4=
github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/elastic/sarama v1.19.1-0.20210823122811-11c3ef800752 h1:5/RUNg7rkIvayjPhAIoI3v8p45NfWcfWs5DZSElycis=
github.com/elastic/sarama v1.19.1-0.20210823122811-11c3ef800752/go.mod h1:mdtqvCSg8JOxk8PmpTNGyo6wzd4BMm4QXSfDnTXmgkE=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc=
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -58924,7 +58924,7 @@ type: keyword
*`system.filesystem.type`*::
+
--
The disk type. For example: `ext4`
The disk type. For example: `ext4`. In some case for Windows OS the value will be `unavailable` as access to this information is not allowed (ex. external disks).


type: keyword
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/fields.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion metricbeat/module/system/filesystem/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
- name: type
type: keyword
description: >
The disk type. For example: `ext4`
The disk type. For example: `ext4`. In some case for Windows OS the value will be `unavailable` as access to this information is not allowed (ex. external disks).
- name: mount_point
type: keyword
description: >
Expand Down
18 changes: 13 additions & 5 deletions metricbeat/module/system/filesystem/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,23 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
}

for _, fs := range fss {
fsStat, err := GetFileSystemStat(fs)
stat, err := GetFileSystemStat(fs)
addStats := true
if err != nil {
debugf("error getting filesystem stats for '%s': %v", fs.DirName, err)
continue
addStats = false
m.Logger().Debugf("error fetching filesystem stats for '%s': %v", fs.DirName, err)
}
AddFileSystemUsedPercentage(fsStat)
fsStat := FSStat{
FileSystemUsage: stat,
DevName: fs.DevName,
Mount: fs.DirName,
SysTypeName: fs.SysTypeName,
}

AddFileSystemUsedPercentage(&fsStat)

event := mb.Event{
MetricSetFields: GetFilesystemEvent(fsStat),
MetricSetFields: GetFilesystemEvent(&fsStat, addStats),
}
if !r.Event(event) {
return nil
Expand Down
29 changes: 12 additions & 17 deletions metricbeat/module/system/filesystem/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,13 @@ func filterFileSystemList(fsList []sigar.FileSystem) []sigar.FileSystem {
}

// GetFileSystemStat retreves stats for a single filesystem
func GetFileSystemStat(fs sigar.FileSystem) (*FSStat, error) {
func GetFileSystemStat(fs sigar.FileSystem) (sigar.FileSystemUsage, error) {
stat := sigar.FileSystemUsage{}
// In some case for Windows OS the disk type value will be `unavailable` and access to this information is not allowed (ex. external disks).
if err := stat.Get(fs.DirName); err != nil {
return nil, err
}

filesystem := FSStat{
FileSystemUsage: stat,
DevName: fs.DevName,
Mount: fs.DirName,
SysTypeName: fs.SysTypeName,
return stat, err
}

return &filesystem, nil
return stat, nil
}

// AddFileSystemUsedPercentage adds usage data to the filesystem struct
Expand All @@ -137,18 +130,20 @@ func AddFileSystemUsedPercentage(f *FSStat) {
}

// GetFilesystemEvent turns a stat struct into a MapStr
func GetFilesystemEvent(fsStat *FSStat) common.MapStr {
func GetFilesystemEvent(fsStat *FSStat, addStats bool) common.MapStr {
evt := common.MapStr{
"type": fsStat.SysTypeName,
"device_name": fsStat.DevName,
"mount_point": fsStat.Mount,
"total": fsStat.Total,
"available": fsStat.Avail,
"free": fsStat.Free,
"used": common.MapStr{
}
if addStats == true {
evt.Put("total", fsStat.Total)
evt.Put("available", fsStat.Avail)
evt.Put("free", fsStat.Free)
evt.Put("used", common.MapStr{
"pct": fsStat.UsedPercent,
"bytes": fsStat.Used,
},
})
}
if runtime.GOOS != "windows" {
evt.Put("files", fsStat.Files)
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/system/filesystem/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestFileSystemList(t *testing.T) {
assert.True(t, (stat.Used >= 0))

if runtime.GOOS != "windows" {
assert.NotEqual(t, "", stat.SysTypeName)
assert.NotEqual(t, "", fs.SysTypeName)
}
}
}
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 @@ -85,7 +85,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
m.Logger().Debugf("error fetching filesystem stats for '%s': %v", fs.DirName, err)
continue
}
m.Logger().Debugf("filesystem: %s total=%d, used=%d, free=%d", stat.Mount, stat.Total, stat.Used, stat.Free)
m.Logger().Debugf("filesystem: %s total=%d, used=%d, free=%d", fs.DirName, stat.Total, stat.Used, stat.Free)

totalFiles += stat.Files
totalSize += stat.Total
Expand Down