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

Add a metric for machine swap capacity #3339

Merged
merged 3 commits into from
Jun 27, 2023
Merged
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
1 change: 1 addition & 0 deletions docs/storage/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,<br>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,<br>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 |
Expand Down
8 changes: 8 additions & 0 deletions metrics/prometheus_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
3 changes: 3 additions & 0 deletions metrics/testdata/prometheus_machine_metrics
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down