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 F30A020EC89 for ; Fri, 26 Apr 2024 16:03:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E024DA14D; Fri, 26 Apr 2024 16:03:24 +0200 (CEST) From: Gabriel Goller To: pbs-devel@lists.proxmox.com Date: Fri, 26 Apr 2024 16:02:42 +0200 Message-ID: <20240426140246.168397-2-g.goller@proxmox.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240426140246.168397-1-g.goller@proxmox.com> References: <20240426140246.168397-1-g.goller@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.076 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [http.rs] Subject: [pbs-devel] [PATCH proxmox v3 1/2] metrics: encode influxdb org and bucket parameters 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" 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 --- 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