Skip to content

Commit

Permalink
[metricbeat] Add windows memory data to docker/memory (#12172)
Browse files Browse the repository at this point in the history
Adding windows memory data to docker/memory
  • Loading branch information
fearful-symmetry authored May 30, 2019
1 parent 167bc1d commit 1c75c66
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 16 deletions.
43 changes: 43 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4539,6 +4539,49 @@ Memory metrics.
[float]
== commit fields
Committed bytes on Windows
*`docker.memory.commit.total`*::
+
--
type: long
format: bytes
Total bytes
--
*`docker.memory.commit.peak`*::
+
--
type: long
format: bytes
Peak committed bytes on Windows
--
*`docker.memory.private_working_set.total`*::
+
--
type: long
format: bytes
private working sets on Windows
--
*`docker.memory.fail.count`*::
+
--
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion metricbeat/module/docker/memory/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,26 @@
Memory metrics.
release: ga
fields:

- name: commit
type: group
description: >
Committed bytes on Windows
fields:
- name: total
type: long
format: bytes
description: >
Total bytes
- name: peak
type: long
format: bytes
description: >
Peak committed bytes on Windows
- name: private_working_set.total
type: long
format: bytes
description: >
private working sets on Windows
- name: fail.count
type: scaled_float
description: >
Expand Down Expand Up @@ -49,3 +68,4 @@
format: bytes
description: >
Total memory usage.
43 changes: 29 additions & 14 deletions metricbeat/module/docker/memory/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,35 @@ func eventsMapping(r mb.ReporterV2, memoryDataList []MemoryData) {
}

func eventMapping(r mb.ReporterV2, memoryData *MemoryData) {
fields := common.MapStr{
"fail": common.MapStr{
"count": memoryData.Failcnt,
},
"limit": memoryData.Limit,
"rss": common.MapStr{
"total": memoryData.TotalRss,
"pct": memoryData.TotalRssP,
},
"usage": common.MapStr{
"total": memoryData.Usage,
"pct": memoryData.UsageP,
"max": memoryData.MaxUsage,
},

//if we have windows memory data, just report windows stats
var fields common.MapStr
if memoryData.Commit+memoryData.CommitPeak+memoryData.PrivateWorkingSet > 0 {
fields = common.MapStr{
"commit": common.MapStr{
"total": memoryData.Commit,
"peak": memoryData.CommitPeak,
},
"private_working_set": common.MapStr{
"total": memoryData.PrivateWorkingSet,
},
}
} else {
fields = common.MapStr{
"fail": common.MapStr{
"count": memoryData.Failcnt,
},
"limit": memoryData.Limit,
"rss": common.MapStr{
"total": memoryData.TotalRss,
"pct": memoryData.TotalRssP,
},
"usage": common.MapStr{
"total": memoryData.Usage,
"pct": memoryData.UsageP,
"max": memoryData.MaxUsage,
},
}
}

r.Event(mb.Event{
Expand Down
8 changes: 8 additions & 0 deletions metricbeat/module/docker/memory/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ type MemoryData struct {
TotalRssP float64
Usage uint64
UsageP float64
//Windows-only memory stats
Commit uint64
CommitPeak uint64
PrivateWorkingSet uint64
}

// MemoryService is placeholder for the the memory stat parsers
Expand Down Expand Up @@ -66,5 +70,9 @@ func (s *MemoryService) getMemoryStats(myRawStat docker.Stat, dedot bool) Memory
TotalRssP: float64(totalRSS) / float64(myRawStat.Stats.MemoryStats.Limit),
Usage: myRawStat.Stats.MemoryStats.Usage,
UsageP: float64(myRawStat.Stats.MemoryStats.Usage) / float64(myRawStat.Stats.MemoryStats.Limit),
//Windows memory statistics
Commit: myRawStat.Stats.MemoryStats.Commit,
CommitPeak: myRawStat.Stats.MemoryStats.CommitPeak,
PrivateWorkingSet: myRawStat.Stats.MemoryStats.PrivateWorkingSet,
}
}

0 comments on commit 1c75c66

Please sign in to comment.