[pdm-devel] [PATCH proxmox-datacenter-manager v7 15/24] api: add endpoint to trigger metric collection

Lukas Wagner l.wagner at proxmox.com
Tue Aug 26 15:51:10 CEST 2025


This one lives under /metric-collection/trigger.
Doing a POST will trigger metric collection for a remote provided in the
'remote' parameter, or all remotes if the parameter is not provided.

Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
Reviewed-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
Reviewed-by: Dominik Csapak <d.csapak at proxmox.com>
Tested-by: Dominik Csapak <d.csapak at proxmox.com>
---
 server/src/api/metric_collection.rs | 27 ++++++---------------------
 server/src/api/mod.rs               |  2 ++
 2 files changed, 8 insertions(+), 21 deletions(-)

diff --git a/server/src/api/metric_collection.rs b/server/src/api/metric_collection.rs
index 0658fb1f..308ceca2 100644
--- a/server/src/api/metric_collection.rs
+++ b/server/src/api/metric_collection.rs
@@ -1,26 +1,17 @@
 use anyhow::Error;
 
+use pdm_api_types::remotes::REMOTE_ID_SCHEMA;
 use proxmox_router::{Router, SubdirMap};
 use proxmox_schema::api;
 use proxmox_sortable_macro::sortable;
 
-use pdm_api_types::{remotes::REMOTE_ID_SCHEMA, MetricCollectionStatus};
-
-use crate::metric_collection;
-
 pub const ROUTER: Router = Router::new().subdirs(SUBDIRS);
 
 #[sortable]
-const SUBDIRS: SubdirMap = &sorted!([
-    (
-        "trigger",
-        &Router::new().post(&API_METHOD_TRIGGER_METRIC_COLLECTION)
-    ),
-    (
-        "status",
-        &Router::new().get(&API_METHOD_GET_METRIC_COLLECTION_STATUS)
-    ),
-]);
+const SUBDIRS: SubdirMap = &sorted!([(
+    "trigger",
+    &Router::new().post(&API_METHOD_TRIGGER_METRIC_COLLECTION)
+),]);
 
 #[api(
     input: {
@@ -34,13 +25,7 @@ const SUBDIRS: SubdirMap = &sorted!([
 )]
 /// Trigger metric collection for a provided remote or for all remotes if no remote is passed.
 pub async fn trigger_metric_collection(remote: Option<String>) -> Result<(), Error> {
-    crate::metric_collection::trigger_metric_collection(remote, false).await?;
+    crate::metric_collection::trigger_metric_collection(remote).await?;
 
     Ok(())
 }
-
-#[api]
-/// Read metric collection status.
-fn get_metric_collection_status() -> Result<Vec<MetricCollectionStatus>, Error> {
-    metric_collection::get_status()
-}
diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs
index 6c4831b4..ff875fc8 100644
--- a/server/src/api/mod.rs
+++ b/server/src/api/mod.rs
@@ -9,6 +9,7 @@ use proxmox_sortable_macro::sortable;
 
 pub mod access;
 pub mod config;
+pub mod metric_collection;
 pub mod nodes;
 pub mod pbs;
 pub mod pve;
@@ -21,6 +22,7 @@ mod rrd_common;
 const SUBDIRS: SubdirMap = &sorted!([
     ("access", &access::ROUTER),
     ("config", &config::ROUTER),
+    ("metric-collection", &metric_collection::ROUTER),
     ("ping", &Router::new().get(&API_METHOD_PING)),
     ("pve", &pve::ROUTER),
     ("pbs", &pbs::ROUTER),
-- 
2.47.2





More information about the pdm-devel mailing list