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

Metricbeat - collects the dockers memory size which is different from “docker stats” #26751

Closed
SperChung-11 opened this issue Jul 7, 2021 · 3 comments · Fixed by #27473
Closed
Labels
bug Team:Integrations Label for the Integrations team

Comments

@SperChung-11
Copy link

Hi,I have met a problem as follows:

i have use metricbeat to collect docker memory, but found that the data of memory (suce as memory usage) was different from the "docker stats", is it right ?
metricbeat: 7.6.0

image

image

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 7, 2021
@ChrsMark ChrsMark added the Team:Integrations Label for the Integrations team label Jul 26, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 26, 2021
@ChrsMark
Copy link
Member

cc: @fearful-symmetry

@fearful-symmetry
Copy link
Contributor

So, I did some digging, and there's actually a fair bit of difference between how we calculate percentages, and I'm guessing that our implementation is based on an outdated version of what docker did. We just do metric/memory_limit for any given memory value, but docker is (now) just a tad more sophisticated:

	// cgroup v1
	if v, isCgroup1 := mem.Stats["total_inactive_file"]; isCgroup1 && v < mem.Usage {
		return float64(mem.Usage - v)
	}
	// cgroup v2
	if v := mem.Stats["inactive_file"]; v < mem.Usage {
		return float64(mem.Usage - v)
	}
	return float64(mem.Usage)

I'm leaning towards calling this a bug, based on how other platforms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants