Skip to content

[Metricbeat] Bump elastic-agent-system-metrics for zswap and cgroups v2 CPU CFS data#49098

Open
orestisfl wants to merge 23 commits intoelastic:mainfrom
orestisfl:zswap-metrics
Open

[Metricbeat] Bump elastic-agent-system-metrics for zswap and cgroups v2 CPU CFS data#49098
orestisfl wants to merge 23 commits intoelastic:mainfrom
orestisfl:zswap-metrics

Conversation

@orestisfl
Copy link
Contributor

@orestisfl orestisfl commented Feb 25, 2026

Proposed commit message

Bumps the elastic-agent-system-metrics dependency to v0.14.3, v0.14.2 also included.

What's Changed

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

None. New features.

  1. Build metricbeat from the branch:
cd metricbeat
mage build
  1. Create a test config file metricbeat.test.yml:
metricbeat.modules:
  - module: system
    period: 5s
    metricsets:
      - memory
      - process
    process.include_top_n:
      by_cpu: 5
      by_memory: 5

output.console:
  pretty: true

logging.level: debug
  1. Run metricbeat:
./metricbeat -e -c metricbeat.test.yml
  1. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with cat /sys/module/zswap/parameters/enabled):
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'

Expected output (values will vary):

{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
  1. To also verify the zswap.debug.* fields (requires debugfs access), grant the binary the cap_dac_read_search capability:
sudo setcap cap_dac_read_search=+ep metricbeat

Then re-run. Expected output with debug fields:

{
  "compressed": 950353920,
  "uncompressed": 3813502976,
  "debug": {
    "decompress_fail": 0,
    "pool_limit_hit": 0,
    "pool_total_size": 950353920,
    "reject_alloc_fail": 0,
    "reject_compress_fail": 0,
    "reject_compress_poor": 0,
    "reject_kmemcache_fail": 0,
    "reject_reclaim_fail": 0,
    "stored_incompressible_pages": 16779,
    "stored_pages": 931031,
    "written_back_pages": 29111
  }
}
  1. Verify cfs.weight appears in process cgroup metrics (requires cgroupsv2):
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
  1. Run unit tests:
cd metricbeat
go test ./module/system/...

Related issues

@orestisfl orestisfl self-assigned this Feb 25, 2026
@orestisfl orestisfl added enhancement backport-skip Skip notification from the automated backport with mergify Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Feb 25, 2026
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Feb 25, 2026
@github-actions
Copy link
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Vale Linting Results

Summary: 1 suggestion found

💡 Suggestions (1)
File Line Rule Message
docs/reference/metricbeat/exported-fields-system.md 810 Elastic.WordChoice Consider using 'select, press, visits' instead of 'hit', unless the term is in the UI.

The Vale linter checks documentation changes against the Elastic Docs style guide.

To use Vale locally or report issues, refer to Elastic style guide for Vale.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

🔍 Preview links for changed docs

@orestisfl orestisfl marked this pull request as ready for review March 4, 2026 15:01
@orestisfl orestisfl requested review from a team as code owners March 4, 2026 15:01
@orestisfl orestisfl requested review from faec and mauri870 March 4, 2026 15:01
@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e3383ff-676c-4630-8fe5-dcbbbc290d33

📥 Commits

Reviewing files that changed from the base of the PR and between ff149f5 and 6eed8f8.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • NOTICE.txt
  • changelog/fragments/1772011445-zswap-metrics.yaml
  • changelog/fragments/1772636540-zswap-metrics.yaml
  • docs/reference/metricbeat/exported-fields-system.md
  • go.mod
  • metricbeat/module/system/fields.go
  • metricbeat/module/system/memory/_meta/fields.yml
  • metricbeat/module/system/process/_meta/fields.yml
  • metricbeat/module/system/test_system.py

📝 Walkthrough

Walkthrough

This pull request adds zswap memory metrics collection to the system memory metricset and introduces cgroupv2 CPU weight metric support to the system.process dataset. Changes include updating the elastic-agent-system-metrics dependency from v0.14.1 to v0.14.3 in go.mod and NOTICE.txt, adding field definitions for zswap compression statistics and debug counters under memory.swap, adding the CPU weight field for cgroup v2 CPU scheduling, updating documentation with the new metric field definitions, and modifying test fixtures to account for the new Linux-specific zswap fields.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses both linked issues: #47605 (zswap metrics) and #47708 (cgroupv2 CPU metrics). All required metrics from /proc/meminfo, /proc/vmstat, and /sys/kernel/debug/zswap are documented; cgroup v2 CPU weight field is added.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the two linked issues: dependency bump to elastic-agent-system-metrics v0.14.3, documentation updates for zswap and CPU metrics, field definitions, and test updates. No extraneous changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@pierrehilbert
Copy link
Contributor

/test



**`system.process.cgroup.cpu.cfs.weight`**
: CPU weight for the cgroup (cgroupv2). Used by the CFS scheduler to determine the share of CPU time available to the cgroup. Range is 1 to 10000, default 100.
Copy link
Member

Choose a reason for hiding this comment

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

Just a curiosity: I assume this metrics apply to EEVDF as well, now that it has been the default Linux scheduler since v6.6. It just feels a bit weird that we still have cfs in the metric name.

Copy link
Contributor

@vishaangelova vishaangelova left a comment

Choose a reason for hiding this comment

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

LGTM, left some small suggestions for your consideration.

Comment on lines +271 to +273
CPU weight for the cgroup (cgroupv2). Used by the CFS
scheduler to determine the share of CPU time available
to the cgroup. Range is 1 to 10000, default 100.
Copy link
Contributor

@vishaangelova vishaangelova Mar 5, 2026

Choose a reason for hiding this comment

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

Suggested change
CPU weight for the cgroup (cgroupv2). Used by the CFS
scheduler to determine the share of CPU time available
to the cgroup. Range is 1 to 10000, default 100.
CPU weight for the cgroup (cgroupv2). Used by the CFS
scheduler to determine the share of CPU time available
to the cgroup. Valid values range from 1 to 10000. The
default value is 100.

- name: zswap
type: group
description: >
zswap compressed swap cache metrics. Available on Linux when zswap is enabled.
Copy link
Contributor

@vishaangelova vishaangelova Mar 5, 2026

Choose a reason for hiding this comment

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

Suggested change
zswap compressed swap cache metrics. Available on Linux when zswap is enabled.
Metrics for the zswap compressed swap cache. Available on Linux when zswap is enabled.

@rdner
Copy link
Member

rdner commented Mar 6, 2026

@orestisfl we should be able to bump github.com/elastic/elastic-agent-system-metrics to v0.14.3 on all active version branches.

Should we backport this PR? Or you planned to address it differently?

@orestisfl orestisfl added backport-active-all Automated backport with mergify to all the active branches and removed backport-skip Skip notification from the automated backport with mergify labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches enhancement Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system.process dataset should support cgroupv2 CPU metrics [Metricbeat] Zswap Metrics

6 participants