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

Feature: Add nanocl stats command to support multiple process monitoring #1144

Closed
leon3s opened this issue Nov 4, 2024 · 13 comments · Fixed by #1227
Closed

Feature: Add nanocl stats command to support multiple process monitoring #1144

leon3s opened this issue Nov 4, 2024 · 13 comments · Fixed by #1227
Labels
cli Include change in `bin/nanocl` client Include change in `crates/nanocld_client` daemon Include change in `bin/nanocld` enhancement New feature or request good first issue Good for newcomers

Comments

@leon3s
Copy link
Member

leon3s commented Nov 4, 2024

Is your feature request related to a problem? Please describe.
Currently, there is no nanocl stats command available, making it difficult for developers to monitor resource usage (e.g., CPU, memory) of processes managed by Nanocl. This can be a significant gap for those who need real-time insight into the performance and resource consumption of multiple processes.

Describe the solution you'd like
Implement a nanocl stats command that can display real-time resource usage for specified processes. This command should accept multiple process names as arguments, allowing usage such as nanocl stats my-process my-second-process, with combined resource statistics output for all specified processes.

Describe alternatives you've considered

  • Using external monitoring tools that may not be tightly integrated with Nanocl, adding setup complexity.
  • Manually checking resource consumption per process using system tools like top or htop, which lacks process-specific integration within Nanocl.

Additional context
Adding a nanocl stats command would greatly enhance the ability to monitor and manage the performance of services within the Nanocl ecosystem. This feature would provide a streamlined way for developers to get real-time metrics on multiple processes, supporting better optimization and troubleshooting efforts.

@leon3s leon3s added enhancement New feature or request good first issue Good for newcomers cli Include change in `bin/nanocl` labels Nov 4, 2024
@n0tank3sh
Copy link
Contributor

@leon3s
Should we use something ratatui for building htop like interface for displaying the stats?

@leon3s
Copy link
Member Author

leon3s commented Mar 7, 2025

Hey, i think that would be pretty overkill and i want to keep things docker like for the commands and the output, so seasoned docker user can jump in nanocl pretty easily.

If you want to use ratatui you can create your own binary to view thing in a better way a bit like:

https://github.com/mrjackwills/oxker

I'll be happy to advertise it if you do

@n0tank3sh
Copy link
Contributor

@leon3s Hey, Sorry for the late response. I am going for building similar to what you have done with cargo stats. The issue I am facing with what I have done and even with cargo stats is that it's getting stuck. Should I open draft pr or should I look into daemon?

@leon3s
Copy link
Member Author

leon3s commented Mar 11, 2025

Wdym by getting stuck ? You don't receive data?

@n0tank3sh
Copy link
Contributor

By getting stuck, I mean it's literally blocking the current thread on when I await for receiver from client.stats_processes.

@leon3s
Copy link
Member Author

leon3s commented Mar 11, 2025

Does it do it when you run the cargo stats command?

@n0tank3sh
Copy link
Contributor

yup,

@leon3s
Copy link
Member Author

leon3s commented Mar 11, 2025

You do it with the development env right?
Could you test with the latest nightly build?

@leon3s
Copy link
Member Author

leon3s commented Mar 11, 2025

I don't have this problem on my machine and on different servers..

@n0tank3sh
Copy link
Contributor

Ok, Tested on the latest nightly build, the issue persist. Here is the video

@leon3s
Copy link
Member Author

leon3s commented Mar 11, 2025

Only the name of the cargo is required, error handling is missing for incorrect naming i guess..
The correct command to get the stats of the daemon should be:

nanocl cargo -n system stats ndaemon

@leon3s
Copy link
Member Author

leon3s commented Mar 11, 2025

To be able to do the issue you need to create a new route on the api similar to this one:
https://github.com/next-hat/nanocl/blob/nightly/bin/nanocld/src/services/process/stats.rs
But for one process only (a process in nanocl is basically a container).
You have to create it on the same file but the endpoint will be /process/{name}/stats
Then in the nanocld_client crate add a client.stats_process function.

@leon3s leon3s added daemon Include change in `bin/nanocld` client Include change in `crates/nanocld_client` labels Mar 11, 2025
@n0tank3sh
Copy link
Contributor

oh, that makes sense. Thank you for your insight. I will use that approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Include change in `bin/nanocl` client Include change in `crates/nanocld_client` daemon Include change in `bin/nanocld` enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants