memory: publish pool allocation counts as gauges (#2721)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-15 17:58:18 +00:00
committed by GitHub
parent 94b0eff655
commit 8fe85c143b
5 changed files with 30 additions and 18 deletions
+2
View File
@@ -215,6 +215,8 @@ Renamed:
| `windows_hyperv_virtual_storage_device_throughput` | `windows_hyperv_virtual_storage_device_throughput_total` | Now a counter, use `rate()` |
| `windows_filetime_mtime_timestamp_seconds` | `windows_file_mtime_timestamp_seconds` | See [filetime](#filetime-collector-removed) |
| `windows_memory_commit_limit` | `windows_memory_commit_limit_bytes` | Unit suffix added, same value |
| `windows_memory_pool_paged_allocs_total` | `windows_memory_pool_paged_allocs` | Now a gauge, query it without `rate()` |
| `windows_memory_pool_nonpaged_allocs_total` | `windows_memory_pool_nonpaged_allocs` | Same value and type (gauge) |
| `windows_smb_server_shares_read_requests_count_total` | `windows_smb_server_shares_read_requests_total` | Same value |
| `windows_smb_server_shares_write_requests_count_total` | `windows_smb_server_shares_write_requests_total` | Same value |
| `windows_smb_server_shares_metadata_requests_count_total` | `windows_smb_server_shares_metadata_requests_total` | Same value |
+2 -2
View File
@@ -34,9 +34,9 @@ None
| `windows_memory_swap_page_writes_total` | Number of disk page writes (a single write operation writing several pages is still only counted once) | counter | None |
| `windows_memory_physical_free_bytes` | Bytes of physical memory currently unused and available | gauge | None |
| `windows_memory_physical_total_bytes` | Total bytes of physical memory available to the operating system. This value does not necessarily indicate the true amount of physical memory, but what is reported to the operating system as available to it | gauge | None |
| `windows_memory_pool_nonpaged_allocs_total` | The number of calls to allocate space in the nonpaged pool. The nonpaged pool is an area of system memory area for objects that cannot be written to disk, and must remain in physical memory as long as they are allocated | gauge | None |
| `windows_memory_pool_nonpaged_allocs` | Number of allocations in the nonpaged pool, regardless of their size. The nonpaged pool is an area of system memory for objects that cannot be written to disk, and must remain in physical memory as long as they are allocated | gauge | None |
| `windows_memory_pool_nonpaged_bytes` | Number of bytes in the non-paged pool, an area of the system virtual memory that is used for objects that cannot be written to disk, but must remain in physical memory as long as they are allocated | gauge | None |
| `windows_memory_pool_paged_allocs_total` | Number of calls to allocate space in the paged pool, regardless of the amount of space allocated in each call | counter | None |
| `windows_memory_pool_paged_allocs` | Number of allocations in the paged pool, regardless of their size | gauge | None |
| `windows_memory_pool_paged_bytes` | Number of bytes in the paged pool | gauge | None |
| `windows_memory_pool_paged_resident_bytes` | The size, in bytes, of the portion of the paged pool that is currently resident and active in physical memory. The paged pool is an area of the system virtual memory that is used for objects that can be written to disk when they are not being used | gauge | None |
| `windows_memory_process_memory_limit_bytes` | Maximum number of bytes of memory that can be allocated to a process | gauge | None |
+11 -11
View File
@@ -64,9 +64,9 @@ type Collector struct {
swapPagesWrittenTotal *prometheus.Desc
swapPageOperationsTotal *prometheus.Desc
swapPageWritesTotal *prometheus.Desc
poolNonPagedAllocationsTotal *prometheus.Desc
poolNonPagedAllocations *prometheus.Desc
poolNonPagedBytes *prometheus.Desc
poolPagedAllocationsTotal *prometheus.Desc
poolPagedAllocations *prometheus.Desc
poolPagedBytes *prometheus.Desc
poolPagedResidentBytes *prometheus.Desc
standbyCacheCoreBytes *prometheus.Desc
@@ -210,9 +210,9 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
nil,
nil,
)
c.poolNonPagedAllocationsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "pool_nonpaged_allocs_total"),
"The number of calls to allocate space in the nonpaged pool. The nonpaged pool is an area of system memory area for objects that cannot be written"+
c.poolNonPagedAllocations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "pool_nonpaged_allocs"),
"Number of allocations in the nonpaged pool, regardless of their size. The nonpaged pool is an area of system memory for objects that cannot be written"+
" to disk, and must remain in physical memory as long as they are allocated (PoolNonpagedAllocs)",
nil,
nil,
@@ -224,9 +224,9 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
nil,
nil,
)
c.poolPagedAllocationsTotal = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "pool_paged_allocs_total"),
"Number of calls to allocate space in the paged pool, regardless of the amount of space allocated in each call (PoolPagedAllocs)",
c.poolPagedAllocations = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "pool_paged_allocs"),
"Number of allocations in the paged pool, regardless of their size (PoolPagedAllocs)",
nil,
nil,
)
@@ -491,7 +491,7 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
)
ch <- prometheus.MustNewConstMetric(
c.poolNonPagedAllocationsTotal,
c.poolNonPagedAllocations,
prometheus.GaugeValue,
c.perfDataObject[0].PoolNonpagedAllocs,
)
@@ -503,8 +503,8 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
)
ch <- prometheus.MustNewConstMetric(
c.poolPagedAllocationsTotal,
prometheus.CounterValue,
c.poolPagedAllocations,
prometheus.GaugeValue,
c.perfDataObject[0].PoolPagedAllocs,
)
+11 -1
View File
@@ -22,6 +22,8 @@ import (
"github.com/prometheus-community/windows_exporter/internal/collector/memory"
"github.com/prometheus-community/windows_exporter/internal/utils/testutils"
dto "github.com/prometheus/client_model/go"
"github.com/stretchr/testify/require"
)
func BenchmarkCollector(b *testing.B) {
@@ -29,5 +31,13 @@ func BenchmarkCollector(b *testing.B) {
}
func TestCollector(t *testing.T) {
testutils.TestCollector(t, memory.New, nil)
families := testutils.TestCollector(t, memory.New, nil)
// "Pool Paged Allocs" and "Pool Nonpaged Allocs" are PERF_COUNTER_RAWCOUNT,
// an instantaneous value.
for _, name := range []string{"windows_memory_pool_paged_allocs", "windows_memory_pool_nonpaged_allocs"} {
require.Contains(t, families, name)
require.Equal(t, dto.MetricType_GAUGE, families[name].GetType(), name)
require.NotContains(t, families, name+"_total")
}
}
+4 -4
View File
@@ -201,12 +201,12 @@ windows_exporter_collector_timeout{collector="udp"} 0
# TYPE windows_memory_physical_free_bytes gauge
# HELP windows_memory_physical_total_bytes The amount of actual physical memory, in bytes.
# TYPE windows_memory_physical_total_bytes gauge
# HELP windows_memory_pool_nonpaged_allocs_total The number of calls to allocate space in the nonpaged pool. The nonpaged pool is an area of system memory area for objects that cannot be written to disk, and must remain in physical memory as long as they are allocated (PoolNonpagedAllocs)
# TYPE windows_memory_pool_nonpaged_allocs_total gauge
# HELP windows_memory_pool_nonpaged_allocs Number of allocations in the nonpaged pool, regardless of their size. The nonpaged pool is an area of system memory for objects that cannot be written to disk, and must remain in physical memory as long as they are allocated (PoolNonpagedAllocs)
# TYPE windows_memory_pool_nonpaged_allocs gauge
# HELP windows_memory_pool_nonpaged_bytes Number of bytes in the non-paged pool, an area of the system virtual memory that is used for objects that cannot be written to disk, but must remain in physical memory as long as they are allocated (PoolNonpagedBytes)
# TYPE windows_memory_pool_nonpaged_bytes gauge
# HELP windows_memory_pool_paged_allocs_total Number of calls to allocate space in the paged pool, regardless of the amount of space allocated in each call (PoolPagedAllocs)
# TYPE windows_memory_pool_paged_allocs_total counter
# HELP windows_memory_pool_paged_allocs Number of allocations in the paged pool, regardless of their size (PoolPagedAllocs)
# TYPE windows_memory_pool_paged_allocs gauge
# HELP windows_memory_pool_paged_bytes (PoolPagedBytes)
# TYPE windows_memory_pool_paged_bytes gauge
# HELP windows_memory_pool_paged_resident_bytes The size, in bytes, of the portion of the paged pool that is currently resident and active in physical memory. The paged pool is an area of the system virtual memory that is used for objects that can be written to disk when they are not being used (PoolPagedResidentBytes)