Skip to content

Add zswap metrics: bytes_used and compression_efficiency - #1337

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
divikchotani-oss:add-zswap-metrics
Aug 25, 2026
Merged

Add zswap metrics: bytes_used and compression_efficiency#1337
kubernetes-prow[bot] merged 1 commit into
kubernetes:masterfrom
divikchotani-oss:add-zswap-metrics

Conversation

@divikchotani-oss

Copy link
Copy Markdown
Contributor

This commit adds tracking for memory/zswap_bytes_used and memory/zswap_compression_efficiency via procfs.

@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 19, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: divikchotani-oss / name: Divik Chotani (368a56c)

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 19, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Welcome @divikchotani-oss!

It looks like this is your first PR to kubernetes/node-problem-detector 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/node-problem-detector has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @divikchotani-oss. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 19, 2026
@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 19, 2026
@AnishShah

Copy link
Copy Markdown

/ok-to-test

@kubernetes-prow kubernetes-prow Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 19, 2026
@ajaysundark

Copy link
Copy Markdown
Contributor

/test pull-npd-e2e-test

Comment thread pkg/systemstatsmonitor/memory_collector_unix.go Outdated
@AnishShah

Copy link
Copy Markdown

/assign @wangzhen127

@divikchotani-oss
divikchotani-oss force-pushed the add-zswap-metrics branch 3 times, most recently from 04da8a4 to 2e971c9 Compare August 20, 2026 21:38
@AnishShah

Copy link
Copy Markdown

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 21, 2026
klog.Fatalf("Error initializing metric for %q: %v", metrics.MemoryDirtyUsedID, err)
}

if _, ok := memoryConfig.MetricsConfigs[string(metrics.MemoryZswapBytesUsedID)]; ok {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add some unit test?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and can you squash the commits after the update?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added unit tests for zswap to the commit and squashed it all into one commit, thanks

@kubernetes-prow kubernetes-prow Bot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 21, 2026

@DigitalVeer DigitalVeer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this update! Can we please update the systemstatsmonitor documentation as well.

Comment on lines +72 to +73
metrics.MemoryZswapBytesUsedID: "compute.googleapis.com/guest/memory/zswap/bytes_used",
metrics.MemoryZswapCompressionEfficiencyID: "compute.googleapis.com/guest/memory/zswap/compression_efficiency",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this metric registered and/or launched? I cannot find any documentation and some issues came up when testing locally.

  1. CreateTimeSeries rejected on both spellings:
control  guest/memory/percent_used            → {}  (accepted)
PR type  guest/memory/zswap/bytes_used        → 400 INVALID_ARGUMENT "unknown metric type"
flat     guest/memory/zswap_bytes_used        → 400 INVALID_ARGUMENT "unknown metric type"
  1. Not in the API descriptors:
$ GET /v3/projects/…/metricDescriptors?filter=starts_with("compute.googleapis.com/guest")
-- No match for zswap
  1. Running on stackdriver fails on every export:
… metric.type="compute.googleapis.com/guest/memory/zswap/compression_efficiency" … unknown metric type
… metric.type="compute.googleapis.com/guest/memory/zswap/bytes_used" … unknown metric type

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi, thanks for the catch! I updated the documentation, the reason for the error is because the metric descriptors have not yet been registered in the backend, once that happens, the errors should be resolved.

@wangzhen127

Copy link
Copy Markdown
Member

/lgtm

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 25, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: AnishShah, divikchotani-oss, wangzhen127

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 25, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit 527383f into kubernetes:master Aug 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants