-
Notifications
You must be signed in to change notification settings - Fork 525
Implement container stats #851
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
base: main
Are you sure you want to change the base?
Conversation
This implements statistics gathering across the various components, but ultimately this is for implementing a new CLI command: `container stats`. This shows memory usage, cpu usage, network and block i/o and the number of processes in the container. The new command can inspect stats for 1-N containers and by default continuously updates in a `top` like stream.
002f619 to
2c386f4
Compare
| memoryUsageBytes: stats.memory.usageBytes, | ||
| memoryLimitBytes: stats.memory.limitBytes, | ||
| cpuUsageUsec: stats.cpu.usageUsec, | ||
| networkRxBytes: stats.networks.reduce(0) { $0 + $1.receivedBytes }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more useful to only reduce these at the command line and make all of these fields arrays? If we did can the caller correlate the entries readily with the config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm inclined to keep it for now, but we can always adjust as needed
| @Option(name: .long, help: "Format of the output") | ||
| var format: ListFormat = .table | ||
|
|
||
| @Flag(name: .long, help: "Disable streaming stats and only pull the first result") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about a stream argument that's an enumeration of follow and top (which might not be 100% sensical now but becomes more so if we add arg-based or interactive sort).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fwiw, I'd like to keep the current set as I have a bit grander plans for the UX eventually (a more fleshed out TUI experience). Currently this mimics the stats view that most other container engines offer, mostly as it's familiar.
| public init() {} | ||
|
|
||
| public func run() async throws { | ||
| if format == .json || noStream { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json + top doesn't make sense, but json + follow would give you JSONL/NDJSON output.
Closes #824
This implements statistics gathering across the various components, but ultimately this is for implementing a new CLI command:
container stats. This shows memory usage, cpu usage, network and block i/o and the number of processes in the container. The new command can inspect stats for 1-N containers and by default continuously updates in atoplike stream.Type of Change
Testing