Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick #8508 to 6.x: Added write and read disk IO times on Metricbeat system module #8565

Merged
merged 2 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ https://github.com/elastic/beats/compare/v6.4.0...6.x[Check the HEAD diff]
- Fixed the location of the modules.d dir in Deb and RPM packages. {issue}8104[8104]
- Add docker diskio stats on Windows. {issue}6815[6815] {pull}8126[8126]
- Fix incorrect type conversion of average response time in Haproxy dashboards {pull}8404[8404]
- Fix dropwizard module parsing of metric names. {issue}8365[8365] {pull}6385[8385]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This happens sometimes when using the backport tool, you will need to remove this line manually

- Added io disk read and write times to system module {issue}8473[8473] {pull}8508[8508]
- Avoid mapping issues in kubernetes module. {pull}8487[8487]

*Packetbeat*
Expand Down
20 changes: 20 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18092,6 +18092,16 @@ format: bytes
The number of Bytes read from the device per second.


--

*`system.diskio.iostat.read.await`*::
+
--
type: float

The average time spent for read requests issued to the device to be served.


--

*`system.diskio.iostat.write.per_sec.bytes`*::
Expand All @@ -18104,6 +18114,16 @@ format: bytes
The number of Bytes write from the device per second.


--

*`system.diskio.iostat.write.await`*::
+
--
type: float

The average time spent for write requests issued to the device to be served.


--

*`system.diskio.iostat.request.avg_size`*::
Expand Down
6 changes: 4 additions & 2 deletions metricbeat/module/system/diskio/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"request": {
"merges_per_sec": 0,
"per_sec": 0
}
},
"await": 0
},
"request": {
"avg_size": 0
Expand All @@ -40,7 +41,8 @@
"request": {
"merges_per_sec": 0,
"per_sec": 0
}
},
"await": 0
}
},
"name": "sda",
Expand Down
10 changes: 10 additions & 0 deletions metricbeat/module/system/diskio/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,22 @@
The number of Bytes read from the device per second.
format: bytes

- name: iostat.read.await
type: float
description: >
The average time spent for read requests issued to the device to be served.

- name: iostat.write.per_sec.bytes
type: float
description: >
The number of Bytes write from the device per second.
format: bytes

- name: iostat.write.await
type: float
description: >
The average time spent for write requests issued to the device to be served.

- name: iostat.request.avg_size
type: float
description: >
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/module/system/diskio/diskio.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {
"per_sec": common.MapStr{
"bytes": extraMetrics.ReadBytesPerSec,
},
"await": extraMetrics.AvgReadAwaitTime,
},
"write": common.MapStr{
"request": common.MapStr{
Expand All @@ -108,6 +109,7 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) {
"per_sec": common.MapStr{
"bytes": extraMetrics.WriteBytesPerSec,
},
"await": extraMetrics.AvgWriteAwaitTime,
},
"queue": common.MapStr{
"avg_size": extraMetrics.AvgQueueSize,
Expand Down
16 changes: 9 additions & 7 deletions metricbeat/module/system/diskio/diskstat.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ type DiskIOMetric struct {
ReadRequestCountPerSec float64 `json:"rrqCps"`
WriteRequestCountPerSec float64 `json:"wrqCps"`
// using bytes instead of sector
ReadBytesPerSec float64 `json:"rBps"`
WriteBytesPerSec float64 `json:"wBps"`
AvgRequestSize float64 `json:"avgrqSz"`
AvgQueueSize float64 `json:"avgquSz"`
AvgAwaitTime float64 `json:"await"`
AvgServiceTime float64 `json:"svctm"`
BusyPct float64 `json:"busy"`
ReadBytesPerSec float64 `json:"rBps"`
WriteBytesPerSec float64 `json:"wBps"`
AvgRequestSize float64 `json:"avgrqSz"`
AvgQueueSize float64 `json:"avgquSz"`
AvgAwaitTime float64 `json:"await"`
AvgReadAwaitTime float64 `json:"r_await"`
AvgWriteAwaitTime float64 `json:"w_await"`
AvgServiceTime float64 `json:"svctm"`
BusyPct float64 `json:"busy"`
}

type DiskIOStat struct {
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/module/system/diskio/diskstat_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func (stat *DiskIOStat) CalIOStatistics(counter disk.IOCountersStat) (DiskIOMetr
result.AvgRequestSize = size
result.AvgQueueSize = queue
result.AvgAwaitTime = wait
result.AvgReadAwaitTime = float64(rd_ticks) / float64(rd_ios)
result.AvgWriteAwaitTime = float64(wr_ticks) / float64(wr_ios)
result.AvgServiceTime = svct
result.BusyPct = 100.0 * float64(ticks) / deltams
if result.BusyPct > 100.0 {
Expand Down
42 changes: 42 additions & 0 deletions metricbeat/module/system/diskio/diskstat_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ package diskio
import (
"testing"

sigar "github.com/elastic/gosigar"

"github.com/shirou/gopsutil/disk"
"github.com/stretchr/testify/assert"

mbtest "github.com/elastic/beats/metricbeat/mb/testing"
Expand Down Expand Up @@ -81,3 +84,42 @@ func TestDataEmptyFilter(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, 10, len(data))
}

func TestDiskIOStat_CalIOStatistics(t *testing.T) {
counter := disk.IOCountersStat{
ReadCount: 13,
WriteCount: 17,
ReadTime: 19,
WriteTime: 23,
Name: "iostat",
}

stat := &DiskIOStat{
lastDiskIOCounters: map[string]disk.IOCountersStat{
"iostat": disk.IOCountersStat{
ReadCount: 3,
WriteCount: 5,
ReadTime: 7,
WriteTime: 11,
Name: "iostat",
},
},
lastCpu: sigar.Cpu{Idle: 100},
curCpu: sigar.Cpu{Idle: 1},
}

expected := DiskIOMetric{
AvgAwaitTime: 24.0 / 22.0,
AvgReadAwaitTime: 1.2,
AvgWriteAwaitTime: 1,
}

got, err := stat.CalIOStatistics(counter)
if err != nil {
t.Fatal(err)
}

assert.Equal(t, expected.AvgAwaitTime, got.AvgAwaitTime)
assert.Equal(t, expected.AvgReadAwaitTime, got.AvgReadAwaitTime)
assert.Equal(t, expected.AvgWriteAwaitTime, got.AvgWriteAwaitTime)
}
2 changes: 1 addition & 1 deletion metricbeat/module/system/fields.go

Large diffs are not rendered by default.