Skip to content

metrics: track sled physical cpu usage.#9560

Merged
jmcarp merged 1 commit intomainfrom
jmcarp/physical-cpu-metrics
Mar 2, 2026
Merged

metrics: track sled physical cpu usage.#9560
jmcarp merged 1 commit intomainfrom
jmcarp/physical-cpu-metrics

Conversation

@jmcarp
Copy link
Copy Markdown
Contributor

@jmcarp jmcarp commented Dec 23, 2025

On sled-agent startup, begin polling physical cpu usage via the cpu:*:sys:cpu_nsec_* kstat. We expose this as sled_cpu:cpu_nsec, and label samples by cpu micro-state (user, idle, etc.).

Part of #9559.

@jmcarp jmcarp force-pushed the jmcarp/physical-cpu-metrics branch from 0f52f6a to 16ce86d Compare December 23, 2025 16:45
@jmcarp jmcarp requested a review from bnaecker December 23, 2025 21:29
Comment thread sled-agent/src/metrics.rs
add_datalink(&log, &mut tracked_links, &kstat_sampler, link)
.await;
}
Message::TrackCpu => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wasn't exactly sure how to handle this. At the moment, we create one target, which checks cpu stats for all cores on the sled, and the core number is a metric field. Alternatively, we could make a target per core, and move the core number to the target. This implementation is a bit simpler, and it matches the approach we take to instrument cpu usage in propolis. But we could switch to a target per core if that makes more sense semantically within oximeter.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the way you have it now is nice.

On sled-agent startup, begin polling physical cpu usage via the
`cpu:*:sys:cpu_nsec_*` kstat. We expose this as `sled_cpu:cpu_nsec`, and label
samples by cpu micro-state (user, idle, etc.).

Part of #9559.
Comment thread sled-agent/src/metrics.rs
add_datalink(&log, &mut tracked_links, &kstat_sampler, link)
.await;
}
Message::TrackCpu => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the way you have it now is nice.

@jmcarp jmcarp force-pushed the jmcarp/physical-cpu-metrics branch from 16ce86d to 9a62fc5 Compare February 27, 2026 18:30
@jmcarp jmcarp marked this pull request as ready for review March 2, 2026 17:33
@jmcarp jmcarp merged commit 2fa9e47 into main Mar 2, 2026
17 checks passed
@jmcarp jmcarp deleted the jmcarp/physical-cpu-metrics branch March 2, 2026 17:33
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.

2 participants