Cherry-pick #27242 to 7.x: Add support for CgroupsV2 in beats, migrate away from gosigar#27346
Merged
fearful-symmetry merged 1 commit intoelastic:7.xfrom Aug 12, 2021
Merged
Conversation
…c#27242) * finish first round of cgroupsv2 support * fix tests * remove old code, fix PctOpt * fix imports * go mod tidy * try to fix make notice again * try again * remove unneeded test files * fix test paths * fix crossbuild issues * fix tests, remove debug statement * change metadata, fight with mapping defs * fix v1 test, remove debug line * somewhat hacky fix for fields issues * fix v1 fetch, update fields again * fix omitempty issue * make update * remove older test * fix tests, cgv1 logic * remove old debug statement * fix issue with how ubuntu mixes cgroups * clean up error handling in libbeat * changes based on feedback, increased error verbosity to try to fix baffling CI errors * fix fields, add more error messages for weird CI bug * I give up, add tons of debug statements * fix issue with docker containers running under hybrid cgroups * fix hostfs state check * fix more broken tests * fix names, log levels * more changes, docs, test * still making the mapping checks happy * fix libbeat code I broke (cherry picked from commit d898533)
Contributor
|
Pinging @elastic/integrations (Team:Integrations) |
Contributor
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
Contributor
|
This pull request is now in conflicts. Could you fix it? 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #27242 to 7.x branch. Original message:
What does this PR do?
This PR accomplishes a few different things:
libbeat. A considerable portion of the code here is pre-existing code fromgosigarthat's been reorganized.optlibrary frommetricbeat/internal/metricstolibbeat, since we use it here too.MapStrmanipulation code in favor of having the data format hard-coded into the structs, and makes the cgroups code overall more "metrics first"Note that supporting cgroups V1 and V2 involves some compromises, as the two versions structure themselves and report data fairly differently, and as such, most of the metrics APIs require the consumer to differentiate between V1 and V2 if they want to access raw metrics. V1 and V2 can also cooexist on the same system, so this must happen on a pid-by-pid basis.
Also, I'm still testing this on V1 and mixed v1/v2 systems, but the code is otherwise ready for review.
There's also the issue of dashboards. The system Docker dashboard relies on many of the V1 fields that aren't present in V2, and I'm not really sure how to deal with them. Last I tried, we don't really have any mechanism for dashboards to operate with the logic of "use this field if present, otherwise use this other field." We may also just want to re-write the dashboard entirely to just use fields that are present in V1 and V2, at the expense of losing some of the visualizations.
Also keep in mind that most of
system/processis going to be aggressively refactored after this, so any issues, unless they're serious, with the code inlibbeat/metric/system/processandmetricbeat/system/processwill almost certainly be fixed as part of 7.16.What's up with cgroupsV2
Cgroups V2 introduces a few major changes compared to cgroups V1, which necessitated a lot of extra code:
cpuacct,memory, etc) have changed dramatically, and in a few cases have merged with other controllers for V2. This requires entirely new metrics code.File structure
For ease of browsing through this PR (Github honestly isn't great at presenting large PRs), here's the breakdown of what's in here:
This also includes:
libbeat/optWhich is mostly existing code that was moved frommetricbeat/internal.cmd/instance,add_process_metadataandadd_docker_metadatato migrate away fromgosigarmetricbeat/internalto deal with moving thelibbeat/optcode.Why is it important?
Cgroups V2 is coming, and is already default on Fedora. It's supported by most other software at this point.
Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.How to test this PR locally
grep cgroup /proc/self/mountinfosystem/processmetricset, as well asadd_process_metadataandadd_docker_metadata