Skip to content

Add resctrl collector - #3797

Merged
SuperQ merged 3 commits into
prometheus:masterfrom
rtreffer:resctrl-collector
Oct 20, 2026
Merged

SuperQ merged 3 commits into
prometheus:masterfrom
rtreffer:resctrl-collector

Conversation

@rtreffer

@rtreffer rtreffer commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Expose the Linux resctrl monitoring counters (Intel RDT, AMD PQoS, ARM MPAM): per L3 domain memory bandwidth (mbm_total_bytes, mbm_local_bytes) and last level cache occupancy (llc_occupancy). Parsing is done by the procfs resctrlfs package.

The collector is disabled by default because the resctrl filesystem must be mounted first (mount -t resctrl resctrl /sys/fs/resctrl). The mountpoint is configurable via --collector.resctrl.path.

Counters a CPU does not support (for example mbm_local_bytes on Arm MPAM) or that read "Unavailable" are skipped per sample. The hardware counters wrap; Prometheus treats the wrap as a counter reset, so no correction is applied.

Depends on a procfs release that contains the resctrlfs package (prometheus/procfs#862).

Signed-off-by: René Treffer [email protected]

Reviewers

AI disclosure: This code was written with the help of AI.
I have read through the code and verified that it works

Here is a snippet showing the metrics as exported by node_exporter built against prometheus/procfs#862

# HELP node_resctrl_llc_occupancy_bytes Last level cache bytes occupied in this domain.
# TYPE node_resctrl_llc_occupancy_bytes gauge
node_resctrl_llc_occupancy_bytes{domain="0"} 3.2014336e+07
node_resctrl_llc_occupancy_bytes{domain="1"} 2.3003136e+07
# HELP node_resctrl_memory_bandwidth_bytes_total Bytes moved between the last level cache and memory. scope=total includes remote sockets, scope=local is memory attached to this domain.
# TYPE node_resctrl_memory_bandwidth_bytes_total counter
node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="local"} 9.866260884132983e+18
node_resctrl_memory_bandwidth_bytes_total{domain="0",scope="total"} 1.8399210738624e+13
node_resctrl_memory_bandwidth_bytes_total{domain="1",scope="local"} 5.010254585456994e+18
node_resctrl_memory_bandwidth_bytes_total{domain="1",scope="total"} 4.003923930496e+12

You can use sum by (instance,node) (rate(node_resctrl_memory_bandwidth_bytes_total{scope="total"}[1m])) to get an estimate of the data transferred between memory and CPU.

This is particularly interesting for workloads like CPU inference, in-memory databases or vector databases.

Caveats: The total value is only available if memory access happened. The metric won't be available on every scrape. We could cache the latest value if this is an issue.

@rtreffer

Copy link
Copy Markdown
Contributor Author

Build error seems unrelate.

collector/runit.go:22:2: github.com/prometheus-community/[email protected]: read "https://proxy.golang.org/github.com/prometheus-community/go-runit/@v/v0.1.0.zip": stream error: stream ID 59; INTERNAL_ERROR; received from peer
!! command failed: build -o .build/darwin-amd64/node_exporter -ldflags -X github.com/prometheus/common/version.Version=1.12.1 -X github.com/prometheus/common/version.Revision=a7efcaa694b0a9b63576ba5218c51e67c41c9a71 -X github.com/prometheus/common/version.Branch=HEAD -X github.com/prometheus/common/version.BuildUser=root@f0de7527c217 -X github.com/prometheus/common/version.BuildDate=20260827-20:09:54  github.com/prometheus/node_exporter: exit status 1
make: *** [Makefile.common:237: common-build] Error 1
!! the main builder docker image exited unexpectedly: exit status 2
Error: Process completed with exit code 1.

The following diff is likely unacceptable at the moment but we need the next tagged procfs version :-)

-	github.com/prometheus/procfs v0.21.1
+	github.com/prometheus/procfs v0.21.2-0.20260827102831-a87803ee31e3

@rtreffer
rtreffer marked this pull request as ready for review August 27, 2026 20:17
@dongjiang1989

Copy link
Copy Markdown
Member

The following diff is likely unacceptable at the moment but we need the next tagged procfs version :-)

Need git rebase.

@rtreffer

rtreffer commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

@dongjiang1989 rebased. diff looks good, procfs is at a tagged version, the Mac OS test needs a rerun.

@dongjiang1989

Copy link
Copy Markdown
Member

@dongjiang1989 rebased. diff looks good, procfs is at a tagged version, the Mac OS test needs a rerun.

U can git commit --amend

@rtreffer
rtreffer force-pushed the resctrl-collector branch 8 times, most recently from 1324402 to 45fd980 Compare September 21, 2026 13:19
@rtreffer

Copy link
Copy Markdown
Contributor Author

I think the e2e tests for Mac OS are broken, even on the main branch, PR #3825

Expose the Linux resctrl monitoring counters (Intel RDT, AMD PQoS,
ARM MPAM): per L3 domain memory bandwidth (mbm_total_bytes,
mbm_local_bytes) and last level cache occupancy (llc_occupancy).
Parsing is done by the procfs resctrlfs package (procfs v0.22.0).

The collector is disabled by default because the resctrl filesystem
must be mounted first (mount -t resctrl resctrl /sys/fs/resctrl). The
mountpoint is configurable via --collector.resctrl.path.

Counters a CPU does not support (for example mbm_local_bytes on Arm
MPAM) or that read "Unavailable" are skipped per sample. The hardware
counters wrap; Prometheus treats the wrap as a counter reset, so no
correction is applied.

Signed-off-by: René Treffer <[email protected]>
@rtreffer

Copy link
Copy Markdown
Contributor Author

@dongjiang1989 it passes now.

@SuperQ SuperQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@SuperQ
SuperQ merged commit 153881b into prometheus:master Oct 20, 2026
17 checks passed
@SuperQ SuperQ mentioned this pull request Nov 18, 2026
SuperQ added a commit that referenced this pull request Nov 18, 2026
The behavior of `node_cpu_frequency_hertz` has changed. There are two different sources
of data for this metric. One from the `cpu` collector, one from the `cpufreq` collector.
Due to historical feature migrations the `cpufreq` collector shares the same subsystem
as the `cpu` collector. This caused conflicting data behavior. An attempt to fix this
was introduced in #3318. This behavior has been reverted to the previous behavior in #3795.

A new flag (`--collector.cpufreq.enable-cpufreq-prefix`) has been introduced that gives
the `cpufreq` a dedicated metric name subsystem (`node_cpufreq_...`). This will likely
be the default in v2.

* [CHANGE] netstat: Use procfs parsers for netstat, snmp and snmp6 #3796
* [CHANGE] edac: Fix no data results #3863
* [CHANGE] nvme: Deprecate metric nvme_namespace_capacity_bytes #3899
* [FEATURE] Add tainted collector for /proc/sys/kernel/tainted #3745
* [FEATURE] Add resctrl collector #3797
* [ENHANCEMENT] netstat: Add new FreeBSD metrics #3334
* [ENHANCEMENT] Add `chip` label to DRM metrics #3572
* [ENHANCEMENT] diskstats: add device-mapper backing device info metric #3676
* [ENHANCEMENT] textfile: support UTF-8 metric and label names #3729
* [ENHANCEMENT] ksmd: add general_profit metric #3778 #3894
* [BUGFIX] edac: Fix printf-style formatting in slog call #3759
* [BUGFIX] fibre_channel: fix crash when attempting to dereference invalid counters #3573
* [BUGFIX] thermal: Fix collecting Darwin temperatures without CPU power status #3767
* [BUGFIX] fibrechannel: Fix for ppc64le #3769
* [BUGFIX] cpu: Revert dup cpu frequency, add node_cpufreq flag #3795
* [BUGFIX] infiniband: skip sysfs reads for excluded devices #3824
* [BUGFIX] bcache: Fix btree_read_average_duration_seconds unit #3828

Signed-off-by: Ben Kochie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants