Skip to content

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

Merged
orestisfl merged 25 commits intoelastic:mainfrom
orestisfl:zswap-metrics
Mar 11, 2026
Merged

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

Conversation

@orestisfl
Copy link
Copy Markdown
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.

How to test this PR locally

  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
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

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

@github-actions
Copy link
Copy Markdown
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
Copy Markdown
Contributor

github-actions bot commented Feb 25, 2026

🔍 Preview links for changed docs

@pierrehilbert
Copy link
Copy Markdown
Contributor

/test

Copy link
Copy Markdown
Member

@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.

@rdner
Copy link
Copy Markdown
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
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Checked workflow run 22862371306 for this PR: it completed successfully, and the only job (check) and all its steps concluded success.

Root cause analysis: there is no failure to diagnose in this run (0 failed jobs, no failing-step logs).

Recommended action: no code/workflow fix needed for this run; if you expected a failure, share the specific run/job URL that failed and I can analyze that one directly.

Tests run in this investigation:

  • Retrieved workflow run metadata
  • Listed workflow jobs and step conclusions
  • Queried failed-job logs (none found)

What is this? | From workflow: PR Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Checked workflow run 22862371348 for this PR (check-docs): all jobs succeeded, so there is no failing step to remediate.

  • Run conclusion: success
  • Job summary: check (66319708696) completed successfully
  • Log review: inspected job logs; no errors/failures were present in the run output

Recommended action: no code/workflow changes needed for this run. If you want, I can analyze a failing run ID instead and provide a targeted fix plan.


What is this? | From workflow: PR Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Key takeaway: workflow run 22862348154 is green, and I found no failing checks to debug.

  • Run: golangci-lint (event: pull_request, branch: zswap-metrics, conclusion: success)
  • Jobs reviewed (all success):
    • lint (ubuntu-latest)
    • lint (windows-latest)
    • lint (macos-latest)
  • Failed-job log scan result: 0 failed jobs (No failed jobs found in this workflow run)

Recommended action: no remediation needed for this run.

Tests run by me: none locally (analysis based on GitHub Actions run/job metadata and failed-job log query).


What is this? | From workflow: PR Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Workflow run 22862371322 for golangci-lint completed successfully; there is no failing job to triage.

Summary:

  • PR: #49098 (zswap-metrics -> main, fork: orestisfl/beats)
  • Jobs: lint (ubuntu-latest) ✅, lint (macos-latest) ✅, lint (windows-latest)
  • Failed job logs: none (failed_jobs=0)

Root cause/fix:

  • No failure detected in this run, so no remediation is required.

Tests run:

  • Inspected GitHub Actions run/job metadata and failed-job logs query for run 22862371322.

Follow-up:

  • No action needed unless a subsequent run fails.

What is this? | From workflow: PR Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@orestisfl orestisfl merged commit eeabffa into elastic:main Mar 11, 2026
207 checks passed
@orestisfl orestisfl deleted the zswap-metrics branch March 11, 2026 11:04
@github-actions
Copy link
Copy Markdown
Contributor

@Mergifyio backport 8.19 9.2 9.3

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Mar 11, 2026

backport 8.19 9.2 9.3

✅ Backports have been created

Details

Cherry-pick of eeabffa has failed:

On branch mergify/bp/8.19/pr-49098
Your branch is up to date with 'origin/8.19'.

You are currently cherry-picking commit eeabffa30.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   NOTICE.txt
	new file:   changelog/fragments/1772011445-zswap-metrics.yaml
	new file:   changelog/fragments/1772636540-zswap-metrics.yaml
	modified:   docs/reference/metricbeat/exported-fields-system.md
	modified:   go.mod
	modified:   go.sum
	modified:   metricbeat/module/system/memory/_meta/fields.yml
	modified:   metricbeat/module/system/process/_meta/fields.yml
	modified:   metricbeat/module/system/test_system.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   metricbeat/module/system/fields.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

mergify bot pushed a commit that referenced this pull request Mar 11, 2026
…v2 CPU CFS data (#49098)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```

(cherry picked from commit eeabffa)

# Conflicts:
#	metricbeat/module/system/fields.go
mergify bot pushed a commit that referenced this pull request Mar 11, 2026
…v2 CPU CFS data (#49098)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```

(cherry picked from commit eeabffa)
mergify bot pushed a commit that referenced this pull request Mar 11, 2026
…v2 CPU CFS data (#49098)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```

(cherry picked from commit eeabffa)
orestisfl added a commit that referenced this pull request Mar 11, 2026
…v2 CPU CFS data (#49098) (#49399)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```

(cherry picked from commit eeabffa)

Co-authored-by: Orestis Floros <orestis.floros@elastic.co>
orestisfl added a commit that referenced this pull request Mar 11, 2026
…v2 CPU CFS data (#49098) (#49400)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```

(cherry picked from commit eeabffa)

Co-authored-by: Orestis Floros <orestis.floros@elastic.co>
orestisfl added a commit that referenced this pull request Mar 11, 2026
…s for zswap and cgroups v2 CPU CFS data (#49398)

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

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```

(cherry picked from commit eeabffa)

# Conflicts:
#	metricbeat/module/system/fields.go

* Resolve cherry-pick conflict by regenerating fields.go

The auto-generated metricbeat/module/system/fields.go had merge
conflict markers from the backport cherry-pick. Regenerated using
`mage fields` based on the successfully merged _meta/fields.yml files.

---------

Co-authored-by: Orestis Floros <orestis.floros@elastic.co>
strawgate pushed a commit that referenced this pull request Mar 11, 2026
…v2 CPU CFS data (#49098)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```
belimawr pushed a commit to belimawr/beats that referenced this pull request Mar 12, 2026
…v2 CPU CFS data (elastic#49098)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```
belimawr pushed a commit to belimawr/beats that referenced this pull request Mar 12, 2026
…v2 CPU CFS data (elastic#49098)

Bumps the elastic-agent-system-metrics dependency to [v0.14.3](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.3), [v0.14.2](https://github.com/elastic/elastic-agent-system-metrics/releases/tag/v0.14.2) also included.

### What's Changed
* Add Zswap Metrics by @orestisfl in elastic/elastic-agent-system-metrics#279
* PULL_REQUEST_TEMPLATE: Remove reference to non-existant CHANGELOG.md by @orestisfl in elastic/elastic-agent-system-metrics#286
* fix: remove shared context timeout from matrix tests by @orestisfl in elastic/elastic-agent-system-metrics#285
* Enable modernize linter and apply suggestions by @orestisfl in elastic/elastic-agent-system-metrics#287
* Use json omitzero for struct-typed fields in cgroup structs by @orestisfl in elastic/elastic-agent-system-metrics#288
* [cgv2] Add CPU CFS quota, period, and weight metrics by @orestisfl in elastic/elastic-agent-system-metrics#281
* Add missing zswap debug metrics by @orestisfl in elastic/elastic-agent-system-metrics#289

## Disruptive User Impact

None. New features.

## How to test this PR locally

1. Build metricbeat from the branch:

```bash
cd metricbeat
mage build
```

2. Create a test config file `metricbeat.test.yml`:

```yaml
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
```

3. Run metricbeat:

```bash
./metricbeat -e -c metricbeat.test.yml
```

4. Verify zswap memory metrics appear in the output (requires Linux with zswap enabled -- check with `cat /sys/module/zswap/parameters/enabled`):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "memory") | .system.memory.zswap'
```

Expected output (values will vary):

```json
{
  "compressed": 950353920,
  "uncompressed": 3813502976
}
```

5. To also verify the `zswap.debug.*` fields (requires debugfs access), grant the binary the `cap_dac_read_search` capability:

```bash
sudo setcap cap_dac_read_search=+ep metricbeat
```

Then re-run. Expected output with debug fields:

```json
{
  "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
  }
}
```

6. Verify `cfs.weight` appears in process cgroup metrics (requires cgroupsv2):

```bash
./metricbeat -e -c metricbeat.test.yml 2>/dev/null | jq 'select(.metricset.name == "process") | .system.process.cgroup.cpu.cfs.weight // empty'
```

7. Run unit tests:

```bash
cd metricbeat
go test ./module/system/...
```
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