From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id ECCB21FF166 for ; Fri, 11 Oct 2024 12:51:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 45A923BBF9; Fri, 11 Oct 2024 12:52:17 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com Date: Fri, 11 Oct 2024 12:51:34 +0200 Message-Id: <20241011105137.131530-11-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241011105137.131530-1-l.wagner@proxmox.com> References: <20241011105137.131530-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.008 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 10/13] pbs-api-types: add types for the new metrics endpoint X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" Signed-off-by: Lukas Wagner --- pbs-api-types/src/metrics.rs | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/pbs-api-types/src/metrics.rs b/pbs-api-types/src/metrics.rs index 23421035..26266529 100644 --- a/pbs-api-types/src/metrics.rs +++ b/pbs-api-types/src/metrics.rs @@ -187,3 +187,69 @@ pub struct MetricServerInfo { #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option, } + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[api( + properties: { + data: { + type: Array, + items: { + type: MetricDataPoint, + } + } + } +)] +/// Return type for the metric API endpoint +pub struct Metrics { + /// List of metric data points, sorted by timestamp + pub data: Vec, +} + +#[api( + properties: { + id: { + type: String, + }, + metric: { + type: String, + }, + timestamp: { + type: Integer, + }, + }, +)] +/// Metric data point +#[derive(Clone, Debug, Deserialize, Serialize)] +pub struct MetricDataPoint { + /// Unique identifier for this metric object, for instance 'node/' + /// or 'qemu/'. + pub id: String, + + /// Name of the metric. + pub metric: String, + + /// Time at which this metric was observed + pub timestamp: i64, + + #[serde(rename = "type")] + pub ty: MetricDataType, + + /// Metric value. + pub value: f64, +} + +#[api] +/// Type of the metric. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)] +#[serde(rename_all = "lowercase")] +pub enum MetricDataType { + /// gauge. + Gauge, + /// counter. + Counter, + /// derive. + Derive, +} + +serde_plain::derive_display_from_serialize!(MetricDataType); +serde_plain::derive_fromstr_from_deserialize!(MetricDataType); -- 2.39.5 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel