metrics: add host usage history - #14156
Draft
nagaboinaramgopal wants to merge 5 commits into
Draft
Conversation
|
This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch. |
Adds a 4.23.0 to 24.0.0 upgrade path. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Store host stats samples in a new host_stats table and expose them through a new listHostsUsageHistory API, the host counterpart of listVirtualMachinesUsageHistory, listSystemVmsUsageHistory and listVolumesUsageHistory. Samples are written on every host stats collection and pruned by the new host.stats.max.retention.time setting (minutes, default 720). Setting it to 0 or less disables storing and pruning.
nagaboinaramgopal
force-pushed
the
feature/host-stats-history
branch
from
September 11, 2026 22:15
d32940a to
a001961
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Depends on #14033. The new table goes into
schema-42300to2400.sql, which #14033 adds, so this branch contains the #14033 commits. Only the last commit,metrics: add host usage history, belongs to this PR. I will rebase once #14033 is merged.This adds a usage history for hosts, the same way it already exists for instances, system VMs and volumes. The host stats collected by the management server are only kept in memory today, so there is no way to see how the CPU, memory and network usage of a host changed over time.
Every collected host stats sample is now stored in a new
host_statstable, and a new admin APIlistHostsUsageHistoryreturns them. It is the host counterpart oflistVirtualMachinesUsageHistory,listSystemVmsUsageHistoryandlistVolumesUsageHistory, supportsid,ids,name(substring),keyword,startdate,enddateand paging, and returns the stats in the sameStatsResponseformat. Only routing hosts are returned.Old samples are removed by the new
host.stats.max.retention.timesetting (minutes, default 720, same asvm.stats.max.retention.time). Setting it to 0 or less stops storing and pruning host stats. The setting is dynamic.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
N/A
How Has This Been Tested?
Unit tests added in
StatsCollectorTest(persisting a sample, cleanup enabled and disabled) andMetricsServiceImplTest(host search, date filters, response mapping), and a smoke testtest_list_hosts_metrics_historyintest_metrics_api.py. Both test classes pass (67 and 26 tests), with checkstyle.Live tested on a KVM zone with two hosts and NFS storage, upgraded from 4.22 to packages built from this branch (on top of #14033). Management server and hosts on Debian 13, MariaDB 11.8.
Upgrade, the new table is created by the 4.23.0.0 to 24.0.0 step:
With the default settings (
host.stats.interval60000,host.stats.max.retention.time720), one sample per host per minute:listHostsUsageHistory(system VM hosts are not returned):A sample from the response:
Retention, changed at runtime with updateConfiguration:
How did you try to break this feature and the system with this change?
A start date after the end date is rejected with 431, a name that matches no host returns an empty list, and paging returns the total count. With the retention set to 0 nothing is stored and nothing is removed, and changing it back resumes storing without a restart. System VM hosts are not included, only routing hosts. The table has no foreign key, so the history of a removed host stays until it is pruned by the retention. The existing instance, system VM and volume usage history APIs and the in-memory host stats used by listHostsMetrics are unchanged.