Skip to content
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

Add cgroup cpu/mem/disk usage metrics #16472

Merged
merged 15 commits into from
May 29, 2024

Conversation

adithyachakilam
Copy link
Contributor

@adithyachakilam adithyachakilam commented May 20, 2024

Description

This PRs expands the existing metrics reported by the Cgroup monitors. Specifically adds the usage for cpu, memory and disk.

Release note

Introduces new usage metrics for cpu and memory cgroups


Key changed/added classes in this PR
  • CgroupCpuMonitor.java
  • CgroupMemoryMonitor.java
  • CgroupDiskMonitor.java

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@arunramani
Copy link
Contributor

Added a few comments but overall, the change looks good to me. Were you able to validate that you were getting the right values for these? One way would be to test your assumptions in Docker and see if your numbers match with what Docker sees.

@adithyachakilam
Copy link
Contributor Author

Were you able to validate that you were getting the right values for these? One way would be to test your assumptions in Docker and see if your numbers match with what Docker sees.

Yeah tested in docker to see the formats match. But for cpu usage percentage, where do you want me to confirm from ?

@arunramani
Copy link
Contributor

Were you able to validate that you were getting the right values for these? One way would be to test your assumptions in Docker and see if your numbers match with what Docker sees.

Yeah tested in docker to see the formats match. But for cpu usage percentage, where do you want me to confirm from ?

The Docker desktop UI displays CPU usage for a container, but I'm not 100% sure if even Docker does it right. But if it does, it'll give you additional confidence.

@adithyachakilam
Copy link
Contributor Author

The Docker desktop UI displays CPU usage for a container, but I'm not 100% sure if even Docker does it right. But if it does, it'll give you additional confidence.

I have tested with Datadog, even though the %s aren't exactly matching up, the spikes are matching. So I think it is safe to assume working fine.

docs/operations/metrics.md Outdated Show resolved Hide resolved
@adithyachakilam adithyachakilam changed the title Add cgroup cpu/mem usage metrics Add cgroup cpu/mem/disk usage metrics May 28, 2024

public CgroupCpuMonitor(CgroupDiscoverer cgroupDiscoverer, final Map<String, String[]> dimensions, String feed)
{
super(feed);
this.cgroupDiscoverer = cgroupDiscoverer;
this.dimensions = dimensions;
try {
Process p = new ProcessBuilder("getconf", "CLK_TCK").start();

Check warning

Code scanning / CodeQL

Executing a command with a relative path Medium

Command with a relative path 'getconf' is executed.
Copy link
Contributor

@suneet-s suneet-s left a comment

Choose a reason for hiding this comment

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

Thanks @adithyachakilam !

@suneet-s suneet-s merged commit a9044ac into apache:master May 29, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants