Skip to content

Add disk and memory percent_used #825

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

Merged
merged 1 commit into from
Dec 15, 2023
Merged

Conversation

kasbert
Copy link
Contributor

@kasbert kasbert commented Sep 26, 2023

Add percentage of disk and memory usage based on the values in disk/bytes_used and memory/bytes_used .

Includes stackdriver configuration with "custom.googleapis.com" as it is not possible to add metrics to "compute.googleapis.com".

Previous PR 824 had a wrong committer.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 26, 2023
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 26, 2023
@k8s-ci-robot
Copy link
Contributor

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

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 26, 2023
@hakman
Copy link
Member

hakman commented Sep 26, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot 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 Sep 26, 2023
@hakman
Copy link
Member

hakman commented Oct 8, 2023

/lgtm
/cc @MartinForReal @mmiranda96
/assign @dchen1107 @vteratipally

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 8, 2023
@MartinForReal
Copy link
Contributor

/lgtm

@@ -58,6 +58,29 @@ func (mc *memoryCollector) collect() {
}
}

if mc.mPercentUsed != nil && meminfo.MemTotal != nil && *meminfo.MemTotal > 0{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need so many percentage memory metrics (and only for Unix)? Shouldn't it just be "used"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a copy from mBytesUsed section.
Personally I don't find much use for other than 'used' metrics and I am happy to remove them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, please remove it. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mmiranda96 I made the changes, please check.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 28, 2023
@kasbert
Copy link
Contributor Author

kasbert commented Oct 29, 2023

/retest-required

@kasbert
Copy link
Contributor Author

kasbert commented Oct 31, 2023

/retest

@hakman
Copy link
Member

hakman commented Oct 31, 2023

@kasbert Seems unrelated:

Oct 31 04:03:58 systemd[1]: Started Node problem detector.
 node-problem-detector[723]: /home/kubernetes/bin/node-problem-detector: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /home/kubernetes/bin/node-problem-detector)
Oct 31 04:03:58 systemd[1]: node-problem-detector.service: Main process exited, code=exited, status=1/FAILURE
Oct 31 04:03:58 systemd[1]: node-problem-detector.service: Failed with result 'exit-code'.
Oct 31 04:04:08 systemd[1]: node-problem-detector.service: Scheduled restart job, restart counter is at 1.
Oct 31 04:04:08 systemd[1]: Stopped Node problem detector.

@hakman
Copy link
Member

hakman commented Nov 1, 2023

/retest

Copy link
Contributor

@mmiranda96 mmiranda96 left a comment

Choose a reason for hiding this comment

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

One small suggestion, but not blocking.

/lgtm

@@ -291,6 +303,9 @@ func (dc *diskCollector) collect() {
opttypes := strings.Join(partition.Opts, ",")
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "free"}, int64(usageStat.Free))
dc.mBytesUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "used"}, int64(usageStat.Used))
if dc.mPercentUsed != nil {
dc.mPercentUsed.Record(map[string]string{deviceNameLabel: deviceName, fsTypeLabel: fstype, mountOptionLabel: opttypes, stateLabel: "used"}, float64(usageStat.UsedPercent))
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't dc.mPercentused always be initialized? If we fail to do so, we fail in line 162, right? We can probably remove the nil check (to match the other metrics).

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 17, 2023
@vteratipally
Copy link
Collaborator

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman, kasbert, MartinForReal, mmiranda96, vteratipally

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 15, 2023
@k8s-ci-robot k8s-ci-robot merged commit bdaa44e into kubernetes:master Dec 15, 2023
@wangzhen127
Copy link
Member

@kasbert This PR has caused us trouble in GKE as the custom metric unexpectedly charged GKE customers. Even though we are switching over to compute.googleapis.com in #1024, I wonder why we need this given we have bytes_used for disk and memory. Aren't those good enough already? We are consulting with COS team within Google and we are considering reverting this PR if this is not really needed. So please let me know if you have any use case here. Thanks!

@kasbert
Copy link
Contributor Author

kasbert commented Mar 19, 2025

@wangzhen127 Percentage is more useful for alerts and metrics. Having them calculated makes things easier. CPU utilization has a percentage already. GCP Ops Agent has these percentages, too.

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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants