From dae7003b220825957c8a27bb30cd244e623e17bf Mon Sep 17 00:00:00 2001 From: Itamar Holder Date: Wed, 21 Jun 2023 11:51:16 +0200 Subject: [PATCH 1/3] Add a machine_swap_bytes metric Signed-off-by: Itamar Holder --- metrics/prometheus_machine.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/metrics/prometheus_machine.go b/metrics/prometheus_machine.go index 181aaf81b3..67e5c13d74 100644 --- a/metrics/prometheus_machine.go +++ b/metrics/prometheus_machine.go @@ -111,6 +111,14 @@ func NewPrometheusMachineCollector(i infoProvider, includedMetrics container.Met return metricValues{{value: float64(machineInfo.MemoryCapacity), timestamp: machineInfo.Timestamp}} }, }, + { + name: "machine_swap_bytes", + help: "Amount of swap memory available on the machine.", + valueType: prometheus.GaugeValue, + getValues: func(machineInfo *info.MachineInfo) metricValues { + return metricValues{{value: float64(machineInfo.SwapCapacity), timestamp: machineInfo.Timestamp}} + }, + }, { name: "machine_dimm_count", help: "Number of RAM DIMM (all types memory modules) value labeled by dimm type.", From 26c4dc676076eb2ec5f767f676501b58dbfd163b Mon Sep 17 00:00:00 2001 From: Itamar Holder Date: Wed, 21 Jun 2023 11:52:54 +0200 Subject: [PATCH 2/3] Add documentation for machine_swap_bytes metric Signed-off-by: Itamar Holder --- docs/storage/prometheus.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/storage/prometheus.md b/docs/storage/prometheus.md index 2756acaf00..a1158ce8d7 100644 --- a/docs/storage/prometheus.md +++ b/docs/storage/prometheus.md @@ -111,6 +111,7 @@ Metric name | Type | Description | Unit (where applicable) | option parameter | `machine_dimm_capacity_bytes` | Gauge | Total RAM DIMM capacity (all types memory modules) value labeled by dimm type,
information is retrieved from sysfs edac per-DIMM API (/sys/devices/system/edac/mc/) introduced in kernel 3.6 | bytes | | | `machine_dimm_count` | Gauge | Number of RAM DIMM (all types memory modules) value labeled by dimm type,
information is retrieved from sysfs edac per-DIMM API (/sys/devices/system/edac/mc/) introduced in kernel 3.6 | | | `machine_memory_bytes` | Gauge | Amount of memory installed on the machine | bytes | | +`machine_swap_bytes` | Gauge | Amount of swap memory available on the machine | bytes | | `machine_node_distance` | Gauge | Distance between NUMA node and target NUMA node | | cpu_topology | `machine_node_hugepages_count` | Gauge | Numer of hugepages assigned to NUMA node | | cpu_topology | `machine_node_memory_capacity_bytes` | Gauge | Amount of memory assigned to NUMA node | bytes | cpu_topology | From 78150d9536a87ec27aaebc50f25268e3244ea78b Mon Sep 17 00:00:00 2001 From: Itamar Holder Date: Sun, 25 Jun 2023 09:47:15 +0300 Subject: [PATCH 3/3] unit test: machine_swap_bytes Signed-off-by: Itamar Holder --- metrics/testdata/prometheus_machine_metrics | 3 +++ 1 file changed, 3 insertions(+) diff --git a/metrics/testdata/prometheus_machine_metrics b/metrics/testdata/prometheus_machine_metrics index c872448318..1b2ccedb23 100644 --- a/metrics/testdata/prometheus_machine_metrics +++ b/metrics/testdata/prometheus_machine_metrics @@ -71,6 +71,9 @@ machine_nvm_capacity{boot_id="boot-id-test",machine_id="machine-id-test",mode="m # HELP machine_scrape_error 1 if there was an error while getting machine metrics, 0 otherwise. # TYPE machine_scrape_error gauge machine_scrape_error 0 +# HELP machine_swap_bytes Amount of swap memory available on the machine. +# TYPE machine_swap_bytes gauge +machine_swap_bytes{boot_id="boot-id-test",machine_id="machine-id-test",system_uuid="system-uuid-test"} 0 1395066363000 # HELP machine_thread_siblings_count Number of CPU thread siblings. # TYPE machine_thread_siblings_count gauge machine_thread_siblings_count{boot_id="boot-id-test",core_id="0",machine_id="machine-id-test",node_id="0",system_uuid="system-uuid-test",thread_id="0"} 2 1395066363000