Skip to content

Commit b4443af

Browse files
authored
Merge pull request #3339 from iholder101/metric/machine-swap-capacity
Add a metric for machine swap capacity
2 parents 4496c94 + 78150d9 commit b4443af

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

docs/storage/prometheus.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Metric name | Type | Description | Unit (where applicable) | option parameter |
111111
`machine_dimm_capacity_bytes` | Gauge | Total RAM DIMM capacity (all types memory modules) value labeled by dimm type,<br>information is retrieved from sysfs edac per-DIMM API (/sys/devices/system/edac/mc/) introduced in kernel 3.6 | bytes | | |
112112
`machine_dimm_count` | Gauge | Number of RAM DIMM (all types memory modules) value labeled by dimm type,<br>information is retrieved from sysfs edac per-DIMM API (/sys/devices/system/edac/mc/) introduced in kernel 3.6 | | |
113113
`machine_memory_bytes` | Gauge | Amount of memory installed on the machine | bytes | |
114+
`machine_swap_bytes` | Gauge | Amount of swap memory available on the machine | bytes | |
114115
`machine_node_distance` | Gauge | Distance between NUMA node and target NUMA node | | cpu_topology |
115116
`machine_node_hugepages_count` | Gauge | Numer of hugepages assigned to NUMA node | | cpu_topology |
116117
`machine_node_memory_capacity_bytes` | Gauge | Amount of memory assigned to NUMA node | bytes | cpu_topology |

metrics/prometheus_machine.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ func NewPrometheusMachineCollector(i infoProvider, includedMetrics container.Met
111111
return metricValues{{value: float64(machineInfo.MemoryCapacity), timestamp: machineInfo.Timestamp}}
112112
},
113113
},
114+
{
115+
name: "machine_swap_bytes",
116+
help: "Amount of swap memory available on the machine.",
117+
valueType: prometheus.GaugeValue,
118+
getValues: func(machineInfo *info.MachineInfo) metricValues {
119+
return metricValues{{value: float64(machineInfo.SwapCapacity), timestamp: machineInfo.Timestamp}}
120+
},
121+
},
114122
{
115123
name: "machine_dimm_count",
116124
help: "Number of RAM DIMM (all types memory modules) value labeled by dimm type.",

metrics/testdata/prometheus_machine_metrics

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ machine_nvm_capacity{boot_id="boot-id-test",machine_id="machine-id-test",mode="m
7171
# HELP machine_scrape_error 1 if there was an error while getting machine metrics, 0 otherwise.
7272
# TYPE machine_scrape_error gauge
7373
machine_scrape_error 0
74+
# HELP machine_swap_bytes Amount of swap memory available on the machine.
75+
# TYPE machine_swap_bytes gauge
76+
machine_swap_bytes{boot_id="boot-id-test",machine_id="machine-id-test",system_uuid="system-uuid-test"} 0 1395066363000
7477
# HELP machine_thread_siblings_count Number of CPU thread siblings.
7578
# TYPE machine_thread_siblings_count gauge
7679
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

0 commit comments

Comments
 (0)