diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 2d2790eb20b..ac9b420f2ca 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -130,6 +130,7 @@ https://github.com/elastic/beats/compare/v6.0.0-alpha2...v6.0.0-beta1[View commi with the system process metricset. The documentation for these metrics already stated that on multi-core systems the percentages could be greater than 100%. {pull}4544[4544] - Remove filters setting from metricbeat modules. {pull}4699[4699] +- Added `type` field to filesystem metrics. {pull}4717[4717] *Packetbeat* diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 278733e95c2..08191e8c8ac 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -8797,6 +8797,14 @@ type: keyword The disk name. For example: `/dev/disk1` +[float] +=== `system.filesystem.type` + +type: keyword + +The disk type. For example: `ext4` + + [float] === `system.filesystem.mount_point` diff --git a/metricbeat/module/system/filesystem/_meta/data.json b/metricbeat/module/system/filesystem/_meta/data.json index 225428eda98..3009b911ff0 100644 --- a/metricbeat/module/system/filesystem/_meta/data.json +++ b/metricbeat/module/system/filesystem/_meta/data.json @@ -4,6 +4,10 @@ "hostname": "host.example.com", "name": "host.example.com" }, + "@metadata": { + "beat": "noindex", + "type": "doc" + }, "metricset": { "module": "system", "name": "filesystem", @@ -11,18 +15,18 @@ }, "system": { "filesystem": { - "available": 38688276480, - "device_name": "none", - "files": 3940352, - "free": 41930997760, - "free_files": 3276976, + "available": 105569656832, + "device_name": "/dev/disk1", + "type": "hfs", + "files": 4294967279 + "free": 105831800832, + "free_files": 4292793781, "mount_point": "/", - "total": 63371726848, + "total": 249779191808, "used": { - "bytes": 21440729088, - "pct": 0.3383 - } + "bytes": 143947390976, + "pct": 0.5763 + }, } - }, - "type": "metricsets" -} \ No newline at end of file + } +} diff --git a/metricbeat/module/system/filesystem/_meta/docs.asciidoc b/metricbeat/module/system/filesystem/_meta/docs.asciidoc index ee216a01ffd..e3aa78f585f 100644 --- a/metricbeat/module/system/filesystem/_meta/docs.asciidoc +++ b/metricbeat/module/system/filesystem/_meta/docs.asciidoc @@ -16,7 +16,9 @@ This metricset is available on: Often there are mounted filesystems that you do not want Metricbeat to report metrics on. A simple strategy to deal with these filesystems is to configure a -drop_event filter that matches the `mount_point` using a regular expression. +drop_event filter that matches the `mount_point` or `type` using a regular +expression. + Below is an example. [source,yaml] diff --git a/metricbeat/module/system/filesystem/_meta/fields.yml b/metricbeat/module/system/filesystem/_meta/fields.yml index 4948bcf1323..c4a180aa630 100644 --- a/metricbeat/module/system/filesystem/_meta/fields.yml +++ b/metricbeat/module/system/filesystem/_meta/fields.yml @@ -12,6 +12,10 @@ type: keyword description: > The disk name. For example: `/dev/disk1` + - name: type + type: keyword + description: > + The disk type. For example: `ext4` - name: mount_point type: keyword description: > diff --git a/metricbeat/module/system/filesystem/doc.go b/metricbeat/module/system/filesystem/doc.go index d344acd22dd..69e2c7b2bcc 100644 --- a/metricbeat/module/system/filesystem/doc.go +++ b/metricbeat/module/system/filesystem/doc.go @@ -5,30 +5,36 @@ for each of the mounted file systems. An example event looks as following: { - "@timestamp": "2016-05-25T20:51:36.813Z", - "beat": { - "hostname": "host.example.com", - "name": "host.example.com" - }, - "metricset": { - "module": "system", - "name": "filesystem", - "rtt": 55 - }, - "system": { - "filesystem": { - "avail": 13838553088, - "device_name": "/dev/disk1", - "files": 60981246, - "free": 14100697088, - "free_files": 3378553, - "mount_point": "/", - "total": 249779191808, - "used": 235678494720, - "used_p": 0.9435 + "@timestamp": "2016-05-23T08:05:34.853Z", + "beat": { + "hostname": "host.example.com", + "name": "host.example.com" + }, + "@metadata": { + "beat": "noindex", + "type": "doc" + }, + "metricset": { + "module": "system", + "name": "filesystem", + "rtt": 115 + }, + "system": { + "filesystem": { + "available": 105569656832, + "device_name": "/dev/disk1", + "type": "hfs", + "files": 4294967279 + "free": 105831800832, + "free_files": 4292793781, + "mount_point": "/", + "total": 249779191808, + "used": { + "bytes": 143947390976, + "pct": 0.5763 + }, + } } - }, - "type": "metricsets" } */ diff --git a/metricbeat/module/system/filesystem/helper.go b/metricbeat/module/system/filesystem/helper.go index c7f6159a27b..f5471f5df26 100644 --- a/metricbeat/module/system/filesystem/helper.go +++ b/metricbeat/module/system/filesystem/helper.go @@ -6,6 +6,8 @@ import ( "path/filepath" "time" + "runtime" + "github.com/elastic/beats/libbeat/common" "github.com/elastic/beats/metricbeat/module/system" sigar "github.com/elastic/gosigar" @@ -16,6 +18,7 @@ type FileSystemStat struct { DevName string `json:"device_name"` Mount string `json:"mount_point"` UsedPercent float64 `json:"used_p"` + SysTypeName string `json:"type"` ctime time.Time } @@ -46,10 +49,18 @@ func GetFileSystemStat(fs sigar.FileSystem) (*FileSystemStat, error) { return nil, err } + var t string + if runtime.GOOS == "windows" { + t = fs.TypeName + } else { + t = fs.SysTypeName + } + filesystem := FileSystemStat{ FileSystemUsage: stat, DevName: fs.DevName, Mount: fs.DirName, + SysTypeName: t, } return &filesystem, nil @@ -66,6 +77,7 @@ func AddFileSystemUsedPercentage(f *FileSystemStat) { func GetFilesystemEvent(fsStat *FileSystemStat) common.MapStr { return common.MapStr{ + "type": fsStat.SysTypeName, "device_name": fsStat.DevName, "mount_point": fsStat.Mount, "total": fsStat.Total, diff --git a/metricbeat/module/system/filesystem/helper_test.go b/metricbeat/module/system/filesystem/helper_test.go index 8c5e37228b2..c0e101b8c7a 100644 --- a/metricbeat/module/system/filesystem/helper_test.go +++ b/metricbeat/module/system/filesystem/helper_test.go @@ -37,6 +37,10 @@ func TestFileSystemList(t *testing.T) { assert.True(t, (stat.Free >= 0)) assert.True(t, (stat.Avail >= 0)) assert.True(t, (stat.Used >= 0)) + + if runtime.GOOS != "windows" { + assert.NotEqual(t, "", stat.SysTypeName) + } } } } diff --git a/metricbeat/tests/system/test_system.py b/metricbeat/tests/system/test_system.py index a339c19feaa..b0f2df4003e 100644 --- a/metricbeat/tests/system/test_system.py +++ b/metricbeat/tests/system/test_system.py @@ -27,7 +27,7 @@ SYSTEM_DISKIO_FIELDS = ["name", "read.count", "write.count", "read.bytes", "write.bytes", "read.time", "write.time", "io.time"] -SYSTEM_FILESYSTEM_FIELDS = ["available", "device_name", "files", "free", +SYSTEM_FILESYSTEM_FIELDS = ["available", "device_name", "type", "files", "free", "free_files", "mount_point", "total", "used.bytes", "used.pct"]