fix network metrics & grafana dashboard

number of top process consumer in config
This commit is contained in:
2025-11-07 20:24:51 +01:00
parent 9bb3f113db
commit 2e950506b7
6 changed files with 99 additions and 39 deletions

View File

@@ -18,8 +18,8 @@ struct MetricInstruments {
memory_total: opentelemetry::metrics::Gauge<u64>,
swap_usage: opentelemetry::metrics::Gauge<u64>,
swap_total: opentelemetry::metrics::Gauge<u64>,
network_rx: opentelemetry::metrics::Counter<u64>,
network_tx: opentelemetry::metrics::Counter<u64>,
network_rx: opentelemetry::metrics::Gauge<u64>,
network_tx: opentelemetry::metrics::Gauge<u64>,
disk_usage: opentelemetry::metrics::Gauge<u64>,
disk_total: opentelemetry::metrics::Gauge<u64>,
process_cpu: opentelemetry::metrics::Gauge<f64>,
@@ -87,12 +87,12 @@ impl MetricsExporter {
.with_description("Total swap in bytes")
.init(),
network_rx: meter
.u64_counter("system_network_rx_bytes_total")
.with_description("Total bytes received")
.u64_gauge("system_network_rx_bytes_per_sec")
.with_description("Bytes received per second")
.init(),
network_tx: meter
.u64_counter("system_network_tx_bytes_total")
.with_description("Total bytes transmitted")
.u64_gauge("system_network_tx_bytes_per_sec")
.with_description("Bytes transmitted per second")
.init(),
disk_usage: meter
.u64_gauge("system_disk_usage_bytes")
@@ -145,8 +145,8 @@ impl MetricsExporter {
if let Some(network_metrics) = &metrics.network {
for net in network_metrics {
let attrs = &[KeyValue::new("interface", net.interface_name.clone())];
self.gauges.network_rx.add(net.rx_bytes_total, attrs);
self.gauges.network_tx.add(net.tx_bytes_total, attrs);
self.gauges.network_rx.record(net.rx_bytes_per_sec, attrs);
self.gauges.network_tx.record(net.tx_bytes_per_sec, attrs);
}
}