From: Dominik Csapak <d.csapak@proxmox.com>
To: Matthias Heiserer <m.heiserer@proxmox.com>,
Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v4 2/6] pbs-api-types: add metrics api types
Date: Tue, 1 Feb 2022 11:11:08 +0100 [thread overview]
Message-ID: <bafb168a-c38c-e295-4a38-e4c04ea04247@proxmox.com> (raw)
In-Reply-To: <23137814-5509-4604-0f47-a2953040072d@proxmox.com>
On 2/1/22 10:55, Matthias Heiserer wrote:
> Two comments inline.
>
> On 17.01.2022 11:48, Dominik Csapak wrote:
>> InfluxDbUdp and InfluxDbHttp for now
>>
>> introduces schemas for host:port and https urls
>>
>> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
>> ---
>> pbs-api-types/src/lib.rs | 15 ++++
>> pbs-api-types/src/metrics.rs | 138 +++++++++++++++++++++++++++++++++++
>> 2 files changed, 153 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..e442b1cf 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]
>> @@ -100,6 +102,7 @@ mod local_macros {
>> macro_rules! DNS_ALIAS_NAME {
>> () => (concat!(r"(?:(?:", DNS_ALIAS_LABEL!() , r"\.)*", DNS_ALIAS_LABEL!(), ")"))
>> }
>> + macro_rules! PORT_REGEX_STR { () =>
>> (r"(?:[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])") }
>> }
>> const_regex! {
>> @@ -113,6 +116,8 @@ const_regex! {
>> pub DNS_NAME_REGEX = concat!(r"^", DNS_NAME!(), r"$");
>> pub DNS_ALIAS_REGEX = concat!(r"^", DNS_ALIAS_NAME!(), r"$");
>> pub DNS_NAME_OR_IP_REGEX = concat!(r"^(?:", DNS_NAME!(), "|", IPRE!(), r")$");
>> + pub HOST_PORT_REGEX = concat!(r"^(?:", DNS_NAME!(), "|", IPRE_BRACKET!(), "):",
>> PORT_REGEX_STR!() ,"$");
>> + pub HTTP_URL_REGEX = concat!(r"^https?://(?:(?:(?:", DNS_NAME!(), "|", IPRE_BRACKET!(),
>> ")(?::", PORT_REGEX_STR!() ,"))|", IPV6RE!(),")(?:/[^\x00-\x1F\x7F]*)?$");
>> pub SHA256_HEX_REGEX = r"^[a-f0-9]{64}$"; // fixme: define in common_regex ?
>> @@ -160,6 +165,8 @@ pub const BLOCKDEVICE_NAME_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&B
>> pub const SUBSCRIPTION_KEY_FORMAT: ApiStringFormat =
>> ApiStringFormat::Pattern(&SUBSCRIPTION_KEY_REGEX);
>> pub const SYSTEMD_DATETIME_FORMAT: ApiStringFormat =
>> ApiStringFormat::Pattern(&SYSTEMD_DATETIME_REGEX);
>> pub const HOSTNAME_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&HOSTNAME_REGEX);
>> +pub const HOST_PORT_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&HOST_PORT_REGEX);
>> +pub const HTTP_URL_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&HTTP_URL_REGEX);
>> pub const DNS_ALIAS_FORMAT: ApiStringFormat =
>> ApiStringFormat::Pattern(&DNS_ALIAS_REGEX);
>> @@ -199,6 +206,14 @@ pub const DNS_NAME_OR_IP_SCHEMA: Schema = StringSchema::new("DNS name or IP addr
>> .format(&DNS_NAME_OR_IP_FORMAT)
>> .schema();
>> +pub const HOST_PORT_SCHEMA: Schema = StringSchema::new("host:port combination (Host can be DNS
>> name or IP address).")
>> + .format(&HOST_PORT_FORMAT)
>> + .schema();
>> +
>> +pub const HTTP_URL_SCHEMA: Schema = StringSchema::new("HTTP(s) url with optional port.")
>> + .format(&HTTP_URL_FORMAT)
>> + .schema();
>> +
>
> In my tests, the port was not optional. A "?" seems to be missing in the regex. Verify with e.g.
> "proxmox-backup-debug api create /config/metricserver/influxdb-http/ --name name --url
> http://localhost"
yes you're right, i missed a '?' in the regex...
i'll send a v5 since i have to rebase on master anyway
>
>> #[cfg(not(target_arch="wasm32"))] // this only makes sense for the serever side
>
> typo: serever -> server
was in the context and not actually part of my patch...
>
>> pub const NODE_SCHEMA: Schema = StringSchema::new("Node name (or 'localhost')")
>> .format(&ApiStringFormat::VerifyFn(|node| {
>> diff --git a/pbs-api-types/src/metrics.rs b/pbs-api-types/src/metrics.rs
>> new file mode 100644
>> index 00000000..239d6c80
>> --- /dev/null
>> +++ b/pbs-api-types/src/metrics.rs
>> @@ -0,0 +1,138 @@
>> +use serde::{Deserialize, Serialize};
>> +
>> +use crate::{
>> + HOST_PORT_SCHEMA, HTTP_URL_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,
>> + },
>> + enable: {
>> + type: bool,
>> + optional: true,
>> + default: true,
>> + },
>> + host: {
>> + schema: HOST_PORT_SCHEMA,
>> + },
>> + 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,
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + /// Enables or disables the metrics server
>> + pub enable: Option<bool>,
>> + /// the host + port
>> + pub host: String,
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + /// The MTU
>> + pub mtu: Option<u16>,
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + pub comment: Option<String>,
>> +}
>> +
>> +#[api(
>> + properties: {
>> + name: {
>> + schema: METRIC_SERVER_ID_SCHEMA,
>> + },
>> + enable: {
>> + type: bool,
>> + optional: true,
>> + default: true,
>> + },
>> + url: {
>> + schema: HTTP_URL_SCHEMA,
>> + },
>> + token: {
>> + type: String,
>> + optional: true,
>> + },
>> + bucket: {
>> + schema: INFLUXDB_BUCKET_SCHEMA,
>> + optional: true,
>> + },
>> + organization: {
>> + schema: INFLUXDB_ORGANIZATION_SCHEMA,
>> + optional: true,
>> + },
>> + "max-body-size": {
>> + type: usize,
>> + optional: true,
>> + default: 25_000_000,
>> + },
>> + "verify-tls": {
>> + 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,
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + /// Enables or disables the metrics server
>> + pub enable: Option<bool>,
>> + /// The base url of the influxdb server
>> + pub url: String,
>> + /// The Optional Token
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + /// The (optional) API token
>> + 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")]
>> + /// The (optional) maximum body size
>> + pub max_body_size: Option<usize>,
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + /// If true, the certificate will be validated.
>> + pub verify_tls: Option<bool>,
>> + #[serde(skip_serializing_if = "Option::is_none")]
>> + pub comment: Option<String>,
>> +}
next prev parent reply other threads:[~2022-02-01 10:11 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-17 10:48 [pbs-devel] [PATCH proxmox/proxmox-backup v4] add metrics server capability Dominik Csapak
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox v4 1/4] proxmox-sys: make some structs serializable Dominik Csapak
2022-02-01 11:39 ` [pbs-devel] applied: " Thomas Lamprecht
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox v4 2/4] proxmox-sys: add FileSystemInformation struct and helper Dominik Csapak
2022-02-01 11:40 ` [pbs-devel] applied: " Thomas Lamprecht
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox v4 3/4] proxmox-async: add connect_to_udp helper Dominik Csapak
2022-02-01 12:02 ` Thomas Lamprecht
2022-02-01 12:13 ` Dominik Csapak
2022-02-01 12:39 ` Thomas Lamprecht
2022-02-01 13:17 ` Wolfgang Bumiller
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox v4 4/4] proxmox-metrics: implement metrics server client code Dominik Csapak
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox-backup v4 1/6] use 'fs_info' from proxmox-sys Dominik Csapak
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox-backup v4 2/6] pbs-api-types: add metrics api types Dominik Csapak
2022-02-01 9:55 ` Matthias Heiserer
2022-02-01 10:11 ` Dominik Csapak [this message]
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox-backup v4 3/6] pbs-config: add metrics config class Dominik Csapak
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox-backup v4 4/6] backup-proxy: decouple stats gathering from rrd update Dominik Csapak
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox-backup v4 5/6] proxmox-backup-proxy: send metrics to configured metrics server Dominik Csapak
2022-01-17 10:48 ` [pbs-devel] [PATCH proxmox-backup v4 6/6] api: add metricserver endpoints Dominik Csapak
2022-02-01 11:01 ` [pbs-devel] [PATCH proxmox/proxmox-backup v4] add metrics server capability Matthias Heiserer
2022-02-01 11:39 ` Thomas Lamprecht
2022-02-01 13:22 ` Matthias Heiserer
2022-02-01 13:26 ` Thomas Lamprecht
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=bafb168a-c38c-e295-4a38-e4c04ea04247@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=m.heiserer@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