public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v3 1/2] metrics: encode influxdb org and bucket parameters
Date: Fri, 26 Apr 2024 16:02:42 +0200	[thread overview]
Message-ID: <20240426140246.168397-2-g.goller@proxmox.com> (raw)
In-Reply-To: <20240426140246.168397-1-g.goller@proxmox.com>

In order to remove the current limitations on the bucket and
organization names, we need to make sure that they are transmitted
correctly. In order to do this, we encode them using the url crate.

This way we support organization/bucket names that include slashes,
whitespaces, etc.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 proxmox-metrics/Cargo.toml           | 1 +
 proxmox-metrics/src/influxdb/http.rs | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/proxmox-metrics/Cargo.toml b/proxmox-metrics/Cargo.toml
index 98e3683..e97d55f 100644
--- a/proxmox-metrics/Cargo.toml
+++ b/proxmox-metrics/Cargo.toml
@@ -18,6 +18,7 @@ openssl.workspace = true
 serde.workspace = true
 serde_json.workspace = true
 tokio = { workspace = true, features = [ "net", "sync" ] }
+url.workspace = true
 
 proxmox-async.workspace = true
 proxmox-http = { workspace = true, features = [ "client" ] }
diff --git a/proxmox-metrics/src/influxdb/http.rs b/proxmox-metrics/src/influxdb/http.rs
index b8c5c1e..8167b59 100644
--- a/proxmox-metrics/src/influxdb/http.rs
+++ b/proxmox-metrics/src/influxdb/http.rs
@@ -93,12 +93,17 @@ impl InfluxDbHttp {
             ""
         };
 
+        let encoded_org: String =
+            url::form_urlencoded::byte_serialize(organization.as_bytes()).collect();
+        let encoded_bucket: String =
+            url::form_urlencoded::byte_serialize(bucket.as_bytes()).collect();
+
         let writeuri = http::uri::Builder::new()
             .scheme(uri_parts.scheme.clone().unwrap())
             .authority(uri_parts.authority.clone().unwrap())
             .path_and_query(format!(
                 "{}/api/v2/write?org={}&bucket={}",
-                base_path, organization, bucket
+                base_path, encoded_org, encoded_bucket
             ))
             .build()?;
 
-- 
2.43.0



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  reply	other threads:[~2024-04-26 14:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 14:02 [pbs-devel] [PATCH proxmox{, -backup} v3 0/2] Remove influxdb bucket name restrictions Gabriel Goller
2024-04-26 14:02 ` Gabriel Goller [this message]
2024-04-26 15:52   ` [pbs-devel] applied: [PATCH proxmox v3 1/2] metrics: encode influxdb org and bucket parameters Thomas Lamprecht
2024-04-30 10:11     ` Gabriel Goller
2024-04-26 14:02 ` [pbs-devel] [PATCH proxmox-backup v3 2/2] api-types: remove influxdb bucket name restrictions Gabriel Goller
2024-04-26 15:57   ` [pbs-devel] applied: " 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=20240426140246.168397-2-g.goller@proxmox.com \
    --to=g.goller@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