Project: Kata Containers (Runtime / Container Runtime)
File: kata-metrics-in-runtime-rs.md

Rust Runtime(runtime-rs) is responsible for: Gather metrics about `shim`. Gather metrics from `hypervisor` (through `channel`). Get metrics from `agent` (through `ttrpc`). Here are listed all the metrics gathered by `runtime-rs`. Current status of each entry is marked as: DONE TODO | STATUS | Metric name | Type | Units | Labels | | | | -- | -- | | | | `katashimagentrpcdurationshistogrammilliseconds`: <br> RPC latency distributions. | `HISTOGRAM` | `milliseconds` | <ul><li>`action` (RPC actions of Kata agent)<ul><li>`grpc.CheckRequest`</li><li>`grpc.CloseStdinRequest`</li><li>`grpc.CopyFileRequest`</li><li>`grpc.CreateContainerRequest`</li><li>`grpc.CreateSandboxRequest`</li><li>`grpc.DestroySandboxRequest`</li><li>`grpc.ExecProcessRequest`</li><li>`grpc.GetMetricsRequest`</li><li>`grpc.GuestDetailsRequest`</li><li>`grpc.ListInterfacesRequest`</li><li>`grpc.ListProcessesRequest`</li><li>`grpc.ListRoutesRequest`</li><li>`grpc.MemHotplugByProbeRequest`</li><li>`grpc.OnlineCPUMemRequest`</li><li>`grpc.PauseContainerRequest`</li><li>`grpc.RemoveContainerRequest`</li><li>`grpc.ReseedRandomDevRequest`</li><li>`grpc.ResumeContainerRequest`</li><li>`grpc.SetGuestDateTimeRequest`</li><li>`grpc.SignalProcessRequest`</li><li>`grpc.StartContainerRequest`</li><li>`grpc.StatsContainerRequest`</li><li>`grpc.TtyWinResizeRequest`</li><li>`grpc.UpdateContainerRequest`</li><li>`grpc.UpdateInterfaceRequest`</li><li>`grpc.UpdateRoutesRequest`</li><li>`grpc.WaitProcessRequest`</li><li>`grpc.WriteStreamRequest`</li></ul></li><li>`sandbox_id`</li></ul> | | | `katashimfds`: <br> Kata containerd shim v2 open FDs. | `GAUGE` | | <ul><li>`sandbox_id`</li></ul> | | | `katashimiostat`: <br> Kata containerd shim v2 process IO statistics. | `GAUGE` | | <ul><li>`item` (see `/proc/<pid>/io`)<ul><li>`cancelledwritebytes`</li><li>`rchar`</li><li>`readbytes`</li><li>`syscr`</li><li>`syscw`</li><li>`wchar`</li><li>`writebytes`</li></ul></li><li>`sandboxid`</li></ul> | | | `katashimnetdev`: <br> Kata containerd shim v2 network devices statistics. | `GAUGE` | | <ul><li>`interface` (network device name)</li><li>`item` (see `/proc/net/dev`)<ul><li>`recvbytes`</li><li>`recvcompressed`</li><li>`recvdrop`</li><li>`recverrs`</li><li>`recvfifo`</li><li>`recvframe`</li><li>`recvmulticast`</li><li>`recvpackets`</li><li>`sentbytes`</li><li>`sentcarrier`</li><li>`sentcolls`</li><li>`sentcompressed`</li><li>`sentdrop`</li><li>`senterrs`</li><li>`sentfifo`</li><li>`sentpackets`</li></ul></li><li>`sandbox_id`</li></ul> | | | `katashimpodoverheadcpu`: <br> Kata Pod overhead for CPU resources(percent). | `GAUGE` | percent | <ul><li>`sandbox_id`</li></ul> | | | `katashimpodoverheadmemoryinbytes`: <br> Kata Pod overhead for memory resources(bytes). | `GAUGE` | `bytes` | <ul><li>`sandbox_id`</li></ul> | | | `katashimprocstat`: <br> Kata containerd shim v2 process statistics. | `GAUGE` | | <ul><li>`item` (see `/proc/<pid>/stat`)<ul><li>`cstime`</li><li>`cutime`</li><li>`stime`</li><li>`utime`</li></ul></li><li>`sandboxid`</li></ul> | | | `katashimprocstatus`: <br> Kata containerd shim v2 process status. | `GAUGE` | | <ul><li>`item` (see `/proc/<pid>/status`)<ul><li>`hugetlbpages`</li><li>`nonvoluntaryctxtswitches`</li><li>`rssanon`</li><li>`rssfile`</li><li>`rssshmem`</li><li>`vmdata`</li><li>`vmexe`</li><li>`vmhwm`</li><li>`vmlck`</li><li>`vmlib`</li><li>`vmpeak`</li><li>`vmpin`</li><li>`vmpmd`</li><li>`vmpte`</li><li>`vmrss`</li><li>`vmsize`</li><li>`vmstk`</li><li>`vmswap`</li><li>`voluntaryctxtswitches`</li></ul></li><li>`sandboxid`</li></ul> | | | `katashimprocesscpusecondstotal`: <br> Total user and system CPU time spent in seconds. | `COUNTER` | `seconds` | <ul><li>`sandboxid`</li></ul> | | | `katashimprocessmaxfds`: <br> Maximum number of open file descriptors. | `GAUGE` | | <ul><li>`sandbox_id`</li></ul> | | | `katashimprocessopenfds`: <br> Number of open file descriptors. | `GAUGE` | | <ul><li>`sandbox_id`</li></ul> | | | `katashimprocessresidentmemorybytes`: <br> Resident memory size in bytes. | `GAUGE` | `bytes` | <ul><li>`sandboxid`</li></ul> | | | `katashimprocessstarttimeseconds`: <br> Start time of the process since `unix` epoch in seconds. | `GAUGE` | `seconds` | <ul><li>`sandboxid`</li></ul> | | | `katashimprocessvirtualmemorybytes`: <br> Virtual memory size in bytes. | `GAUGE` | `bytes` | <ul><li>`sandboxid`</li></ul> | | | `katashimprocessvirtualmemorymaxbytes`: <br> Maximum amount of virtual memory available in bytes. | `GAUGE` | `bytes` | <ul><li>`sandbox_id`</li></ul> | | | `katashimrpcdurationshistogrammilliseconds`: <br> RPC latency distributions. | `HISTOGRAM` | `milliseconds` | <ul><li>`action` (Kata shim v2 actions)<ul><li>`checkpoint`</li><li>`closeio`</li><li>`connect`</li><li>`create`</li><li>`delete`</li><li>`exec`</li><li>`kill`</li><li>`pause`</li><li>`pids`</li><li>`resizepty`</li><li>`resume`</li><li>`shutdown`</li><li>`start`</li><li>`state`</li><li>`stats`</li><li>`update`</li><li>`wait`</li></ul></li><li>`sandboxid`</li></ul> | | | `katashimthreads`: <br> Kata containerd shim v2 process threads. | `GAUGE` | | <ul><li>`sandbox_id`</li></ul> | Different from golang runtime, hypervisor and shim in runtime-rs belong to the same process, so all previous metrics for hypervisor and shim only need to be gathered once. Thus, we currently only collect previous metrics in kata shim. At the same time, we added the interface(`VmmAction::GetHypervisorMetrics`) to gather hypervisor metrics, in case we design tailor-made metrics for hypervisor in the future. Here're metrics exposed from . | Metric name | Type | Units | Labels | | | - | -- | | | `katahypervisorscrapecount`: <br> Metrics scrape count | `COUNTER` | | <ul><li>`sandboxid`</li></ul> | | `katahypervisorvcpu`: <br>Hypervisor metrics specific to VCPUs' mode of functioning. | `IntGauge` | | <ul><li>`item`<ul><li>`exitioin`</li><li>`exitioout`</li><li>`exitmmioread`</li><li>`exitmmiowrite`</li><li>`failures`</li><li>`filtercpuid`</li></ul></li><li>`sandboxid`</li></ul> | | `katahypervisorseccomp`: <br> Hypervisor metrics for the seccomp filtering. | `IntGauge` | | <ul><li>`item`<ul><li>`numfaults`</li></ul></li><li>`sandboxid`</li></ul> | | `katahypervisorseccomp`: <br> Hypervisor metrics for the seccomp filtering. | `IntGauge` | | <ul><li>`item`<ul><li>`sigbus`</li><li>`sigsegv`</li></ul></li><li>`sandbox_id`</li></ul> |