diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 86cef5977ff..191a0dd7766 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -17,6 +17,7 @@ - **XO 6:** - [i18n] Add Swedish, update Czech and Spanish translations (contributions made by [@xiscoj](https://github.com/xiscoj), [@p-bo](https://github.com/p-bo) and [Jonas](https://translate.vates.tech/user/Jonas/)) (PR [#8294](https://github.com/vatesfr/xen-orchestra/pull/8294)) - [i18n] Merge XO 6 translations files into one file in web-core ([PR #8380](https://github.com/vatesfr/xen-orchestra/pull/8380)) +- [REST API] VM/Host stats available at `/rest/v0///stats` (PR [#8378](https://github.com/vatesfr/xen-orchestra/pull/8378)) ### Bug fixes diff --git a/packages/xo-server/src/xo-mixins/rest-api.mjs b/packages/xo-server/src/xo-mixins/rest-api.mjs index 1ea8837be4c..476a8e4d764 100644 --- a/packages/xo-server/src/xo-mixins/rest-api.mjs +++ b/packages/xo-server/src/xo-mixins/rest-api.mjs @@ -1356,6 +1356,18 @@ export default class RestApi { }) ) + api.get( + '/:collection(vms|hosts)/:object/stats', + wrap(async (req, res) => { + const object = req.object + const method = object.type === 'VM' ? 'getXapiVmStats' : 'getXapiHostStats' + const granularity = req.query.granularity + + const result = await app[method](object.id, granularity) + return res.json(result) + }) + ) + api.get('/:collection/:object', (req, res, next) => { const { collection } = req if (swaggerEndpoints.includes(collection.id)) {