public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup v2 2/6] pbs-api-types: add metrics api types
Date: Wed, 15 Dec 2021 10:19:48 +0100	[thread overview]
Message-ID: <20211215091952.1490583-6-d.csapak@proxmox.com> (raw)
In-Reply-To: <20211215091952.1490583-1-d.csapak@proxmox.com>

InfluxDbUdp and InfluxDbHttp for now

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 pbs-api-types/src/lib.rs     |   2 +
 pbs-api-types/src/metrics.rs | 134 +++++++++++++++++++++++++++++++++++
 2 files changed, 136 insertions(+)
 create mode 100644 pbs-api-types/src/metrics.rs

diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs
index 0a0dd33d..09bd59c8 100644
--- a/pbs-api-types/src/lib.rs
+++ b/pbs-api-types/src/lib.rs
@@ -88,6 +88,8 @@ pub use traffic_control::*;
 mod zfs;
 pub use zfs::*;
 
+mod metrics;
+pub use metrics::*;
 
 #[rustfmt::skip]
 #[macro_use]
diff --git a/pbs-api-types/src/metrics.rs b/pbs-api-types/src/metrics.rs
new file mode 100644
index 00000000..c7e08885
--- /dev/null
+++ b/pbs-api-types/src/metrics.rs
@@ -0,0 +1,134 @@
+use serde::{Deserialize, Serialize};
+
+use crate::{DNS_NAME_OR_IP_SCHEMA, PROXMOX_SAFE_ID_FORMAT, SINGLE_LINE_COMMENT_SCHEMA};
+use proxmox_schema::{api, Schema, StringSchema, Updater};
+
+pub const METRIC_SERVER_ID_SCHEMA: Schema = StringSchema::new("Metrics Server ID.")
+    .format(&PROXMOX_SAFE_ID_FORMAT)
+    .min_length(3)
+    .max_length(32)
+    .schema();
+
+pub const INFLUXDB_BUCKET_SCHEMA: Schema = StringSchema::new("InfluxDB Bucket.")
+    .format(&PROXMOX_SAFE_ID_FORMAT)
+    .min_length(3)
+    .max_length(32)
+    .default("proxmox")
+    .schema();
+
+pub const INFLUXDB_ORGANIZATION_SCHEMA: Schema = StringSchema::new("InfluxDB Organization.")
+    .format(&PROXMOX_SAFE_ID_FORMAT)
+    .min_length(3)
+    .max_length(32)
+    .default("proxmox")
+    .schema();
+
+#[api(
+    properties: {
+        name: {
+            schema: METRIC_SERVER_ID_SCHEMA,
+        },
+        host: {
+            schema: DNS_NAME_OR_IP_SCHEMA,
+        },
+        port: {
+            description: "The port",
+            type: u16,
+        },
+        mtu: {
+            description: "The MTU",
+            type: u16,
+            optional: true,
+            default: 1500,
+        },
+        comment: {
+            optional: true,
+            schema: SINGLE_LINE_COMMENT_SCHEMA,
+        },
+    },
+)]
+#[derive(Serialize, Deserialize, Updater)]
+#[serde(rename_all = "kebab-case")]
+/// InfluxDB Server (UDP)
+pub struct InfluxDbUdp {
+    #[updater(skip)]
+    pub name: String,
+    pub host: String,
+    pub port: u16,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub mtu: Option<u16>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub comment: Option<String>,
+}
+
+#[api(
+    properties: {
+        name: {
+            schema: METRIC_SERVER_ID_SCHEMA,
+        },
+        host: {
+            schema: DNS_NAME_OR_IP_SCHEMA,
+        },
+        https: {
+            description: "If true, HTTPS is used.",
+            type: bool,
+            optional: true,
+            default: true,
+        },
+        token: {
+            description: "The (optional) API token",
+            type: String,
+            optional: true,
+        },
+        bucket: {
+            schema: INFLUXDB_BUCKET_SCHEMA,
+            optional: true,
+        },
+        organization: {
+            schema: INFLUXDB_ORGANIZATION_SCHEMA,
+            optional: true,
+        },
+        "max-body-size": {
+            description: "The (optional) maximum body size",
+            type: usize,
+            optional: true,
+            default: 25_000_000,
+        },
+        "verify-tls": {
+            description: "If true, the certificate will be validated.",
+            type: bool,
+            optional: true,
+            default: true,
+        },
+        comment: {
+            optional: true,
+            schema: SINGLE_LINE_COMMENT_SCHEMA,
+        },
+    },
+)]
+#[derive(Serialize, Deserialize, Updater)]
+#[serde(rename_all = "kebab-case")]
+/// InfluxDB Server (HTTP(s))
+pub struct InfluxDbHttp {
+    #[updater(skip)]
+    pub name: String,
+    pub host: String,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    /// The (optional) port. (defaults: 80 for HTTP, 443 for HTTPS)
+    pub port: Option<u16>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub https: Option<bool>,
+    /// The Optional Token
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub token: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub bucket: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub organization: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub max_body_size: Option<usize>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub verify_tls: Option<bool>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub comment: Option<String>,
+}
-- 
2.30.2





  parent reply	other threads:[~2021-12-15  9:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-15  9:19 [pbs-devel] [PATCH proxmox/proxmox-backup v2] add metrics server capability Dominik Csapak
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox v2 1/3] proxmox-sys: make some structs serializable Dominik Csapak
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox v2 2/3] proxmox-sys: add DiskUsage struct and helper Dominik Csapak
2021-12-15 12:41   ` Thomas Lamprecht
2021-12-16  8:15     ` Dominik Csapak
2021-12-16  8:20       ` Thomas Lamprecht
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox v2 3/3] proxmox-metrics: implement metrics server client code Dominik Csapak
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox-backup v2 1/6] use 'disk_usage' from proxmox-sys Dominik Csapak
2021-12-15  9:19 ` Dominik Csapak [this message]
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox-backup v2 3/6] pbs-config: add metrics config class Dominik Csapak
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox-backup v2 4/6] backup-proxy: decouple stats gathering from rrd update Dominik Csapak
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox-backup v2 5/6] proxmox-backup-proxy: send metrics to configured metrics server Dominik Csapak
2021-12-15  9:19 ` [pbs-devel] [PATCH proxmox-backup v2 6/6] api: add metricserver endpoints Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211215091952.1490583-6-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal