[pbs-devel] [PATCH proxmox v3 1/2] metrics: encode influxdb org and bucket parameters
Gabriel Goller
g.goller at proxmox.com
Fri Apr 26 16:02:42 CEST 2024
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 at 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
More information about the pbs-devel
mailing list