From 757f88be04b5aedbbce009d6d8bade62a583251e Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Sat, 19 Jun 2021 08:24:21 +1000 Subject: [PATCH] Add missing process counters Working Set Private and Working Set Peak were being collected, but not exposed by the exporter. Signed-off-by: Ben Reedy --- collector/process.go | 32 ++++++++++++++++++++++++++++++++ docs/collector.process.md | 2 ++ 2 files changed, 34 insertions(+) diff --git a/collector/process.go b/collector/process.go index 29d02416..e86c89ec 100644 --- a/collector/process.go +++ b/collector/process.go @@ -42,6 +42,8 @@ type processCollector struct { PrivateBytes *prometheus.Desc ThreadCount *prometheus.Desc VirtualBytes *prometheus.Desc + WorkingSetPrivate *prometheus.Desc + WorkingSetPeak *prometheus.Desc WorkingSet *prometheus.Desc processWhitelistPattern *regexp.Regexp @@ -129,6 +131,18 @@ func newProcessCollector() (Collector, error) { []string{"process", "process_id", "creating_process_id"}, nil, ), + WorkingSetPrivate: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "working_set_private_bytes"), + "Size of the working set, in bytes, that is use for this process only and not shared nor sharable by other processes.", + []string{"process", "process_id", "creating_process_id"}, + nil, + ), + WorkingSetPeak: prometheus.NewDesc( + prometheus.BuildFQName(Namespace, subsystem, "working_set_peak_bytes"), + "Maximum size, in bytes, of the Working Set of this process at any point in time. The Working Set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the Working Set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from Working Sets. If they are needed they will then be soft-faulted back into the Working Set before they leave main memory.", + []string{"process", "process_id", "creating_process_id"}, + nil, + ), WorkingSet: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "working_set"), "Maximum number of bytes in the working set of this process at any point in time. The working set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the working set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from working sets. If they are needed, they are then soft-faulted back into the working set before they leave main memory.", @@ -380,6 +394,24 @@ func (c *processCollector) Collect(ctx *ScrapeContext, ch chan<- prometheus.Metr cpid, ) + ch <- prometheus.MustNewConstMetric( + c.WorkingSetPrivate, + prometheus.GaugeValue, + process.WorkingSetPrivate, + processName, + pid, + cpid, + ) + + ch <- prometheus.MustNewConstMetric( + c.WorkingSetPeak, + prometheus.GaugeValue, + process.WorkingSetPeak, + processName, + pid, + cpid, + ) + ch <- prometheus.MustNewConstMetric( c.WorkingSet, prometheus.GaugeValue, diff --git a/docs/collector.process.md b/docs/collector.process.md index 70638555..ed1ccde4 100644 --- a/docs/collector.process.md +++ b/docs/collector.process.md @@ -53,6 +53,8 @@ Name | Description | Type | Labels `windows_process_private_bytes` | _Not yet documented_ | gauge | `process`, `process_id`, `creating_process_id` `windows_process_thread_count` | _Not yet documented_ | gauge | `process`, `process_id`, `creating_process_id` `windows_process_virtual_bytes` | _Not yet documented_ | gauge | `process`, `process_id`, `creating_process_id` +`windows_process_working_set_private_bytes` | _Not yet documented_ | gauge | `process`, `process_id`, `creating_process_id` +`windows_process_working_set_peak_bytes` | _Not yet documented_ | gauge | `process`, `process_id`, `creating_process_id` `windows_process_working_set` | _Not yet documented_ | gauge | `process`, `process_id`, `creating_process_id` ### Example metric