⏱ metrics-process
This crate provides Prometheus style process metrics collector of metrics crate for Linux, macOS, and Windows. Collector code is manually re-written to Rust from an official prometheus client of go (client_golang)
Supported metrics
This crate supports the following metrics, equal to what official prometheus client of go (client_golang) provides.
Metric name | Help string | Linux | macOS | Windows |
---|---|---|---|---|
process_cpu_seconds_total |
Total user and system CPU time spent in seconds. | x | x | x |
process_open_fds |
Number of open file descriptors. | x | x | x |
process_max_fds |
Maximum number of open file descriptors. | x | x | x |
process_virtual_memory_bytes |
Virtual memory size in bytes. | x | x | x |
process_virtual_memory_max_bytes |
Maximum amount of virtual memory available in bytes. | x | x | |
process_resident_memory_bytes |
Resident memory size in bytes. | x | x | x |
process_heap_bytes |
Process heap size in bytes. | |||
process_start_time_seconds |
Start time of the process since unix epoch in seconds. | x | x | x |
process_threads |
Number of OS threads in the process. | x | x |
Usage
Use this crate with metrics-exporter-prometheus as an exporter like:
use thread;
use ;
use PrometheusBuilder;
use Collector;
let builder = new;
builder
.install
.expect;
let collector = default;
// Call `describe()` method to register help string.
collector.describe;
loop
Or with axum (or any web application framework you like) to collect metrics whenever
the /metrics
endpoint is invoked like:
use ;
use PrometheusBuilder;
use Collector;
async
Difference from metrics-process-promstyle
It seems metrics-process-promstyle only support Linux but this crate (metrics-process) supports Linux, macOS, and Windows.
Additionally, this crate supports process_open_fds
and process_max_fds
addition to what metrics-process-promstyle supports.
License
The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.