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

Use working set bytes if usage bytes is zero #25428

Merged
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix GCP not able to request Cloudfunctions metrics if a region filter was set {pull}24218[24218]
- Fix type of `uwsgi.status.worker.rss` type. {pull}24468[24468]
- Accept text/plain type by default for prometheus client scraping. {pull}24622[24622]
- Use working set bytes to calculate the pod memory limit pct when memory usage is not reported (ie. Windows pods). {pull}25428[25428]
- Fix copy-paste error in libbeat docs. {pull}25448[25448]

*Packetbeat*
Expand Down
22 changes: 16 additions & 6 deletions metricbeat/module/kubernetes/pod/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,26 @@ func eventMapping(content []byte, perfMetrics *util.PerfMetricsCache) ([]common.
podEvent.Put("cpu.usage.node.pct", float64(usageNanoCores)/1e9/nodeCores)
}

if nodeMem > 0 {
podEvent.Put("memory.usage.node.pct", float64(usageMem)/nodeMem)
}

if coresLimit > 0 {
podEvent.Put("cpu.usage.limit.pct", float64(usageNanoCores)/1e9/coresLimit)
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
}

if memLimit > 0 {
podEvent.Put("memory.usage.limit.pct", float64(usageMem)/memLimit)
if usageMem > 0 {
if nodeMem > 0 {
podEvent.Put("memory.usage.node.pct", float64(usageMem)/nodeMem)
}
if memLimit > 0 {
podEvent.Put("memory.usage.limit.pct", float64(usageMem)/memLimit)
}
jsoriano marked this conversation as resolved.
Show resolved Hide resolved
}

if workingSet > 0 && usageMem == 0 {
if nodeMem > 0 {
podEvent.Put("memory.usage.node.pct", float64(workingSet)/nodeMem)
}
if memLimit > 0 {
podEvent.Put("memory.usage.limit.pct", float64(workingSet)/memLimit)
}
}

events = append(events, podEvent)
Expand Down