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

feat(host_metrics source): Add process virtual memory metric #22183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/add_virtual_memory_process_metric.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Add virtual memory metric to the process host metrics collector.

authors: nionata
6 changes: 6 additions & 0 deletions src/sources/host_metrics/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct ProcessConfig {
const RUNTIME: &str = "process_runtime";
const CPU_USAGE: &str = "process_cpu_usage";
const MEMORY_USAGE: &str = "process_memory_usage";
const MEMORY_VIRTUAL_USAGE: &str = "process_memory_virtual_usage";

impl HostMetrics {
pub async fn process_metrics(&self, output: &mut super::MetricsBuffer) {
Expand Down Expand Up @@ -46,6 +47,11 @@ impl HostMetrics {
};
output.gauge(CPU_USAGE, process.cpu_usage().into(), tags());
output.gauge(MEMORY_USAGE, process.memory() as f64, tags());
output.gauge(
MEMORY_VIRTUAL_USAGE,
process.virtual_memory() as f64,
tags(),
);
output.counter(RUNTIME, process.run_time() as f64, tags());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ components: sources: host_metrics: {
process_runtime: _host & _process_counter & {description: "The process uptime."}
process_cpu_usage: _host & _process_gauge & {description: "The process CPU usage."}
process_memory_usage: _host & _process_gauge & {description: "The process memory usage."}
process_memory_virtual_usage: _host & _process_gauge & {description: "The process virtual memory usage."}

// Host cgroups
cgroup_cpu_usage_seconds_total: _host & _cgroup_cpu & {description: "The total amount CPU time used by this cgroup and its descendants, in seconds."}
Expand Down