From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D25A163D0A for ; Thu, 27 Jan 2022 13:53:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CA53722BBB for ; Thu, 27 Jan 2022 13:53:25 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 17B0122BB2 for ; Thu, 27 Jan 2022 13:53:25 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E13E7457C6 for ; Thu, 27 Jan 2022 13:53:24 +0100 (CET) From: Markus Frank To: pve-devel@lists.proxmox.com Date: Thu, 27 Jan 2022 13:52:55 +0100 Message-Id: <20220127125255.65105-1-m.frank@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: [pve-devel] [PATCH manager v2] fix #3815: influxdb vmname should be string X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2022 12:53:25 -0000 InfluxDB interprets the vmname 66601 as a number and the vmname vm42 as a String. This leads to problematic metrics, that will be dropped by influxdb. Whichever comes first decides how the "schema" is defined. To change that I added a $quoted hashmap to quote a value. In this case the value of name. nodename and host are tags in InfluxDB so the only value they are able to contain are strings: https://docs.influxdata.com/influxdb/v2.1/reference/syntax/line-protocol/ Signed-off-by: Markus Frank --- PVE/Status/InfluxDB.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm index def7e2fd..d63e18ac 100644 --- a/PVE/Status/InfluxDB.pm +++ b/PVE/Status/InfluxDB.pm @@ -276,6 +276,7 @@ sub test_connection { sub build_influxdb_payload { my ($class, $txn, $data, $ctime, $tags, $excluded, $measurement, $instance) = @_; + my $quoted = { name => 1 }; my @values = (); foreach my $key (sort keys %$data) { @@ -283,6 +284,10 @@ sub build_influxdb_payload { my $value = $data->{$key}; next if !defined($value); + if (defined($quoted) && $quoted->{$key}) { + $value =~ s/\"/\\\"/g; + $value = "\"$value\""; + } if (!ref($value) && $value ne '') { # value is scalar -- 2.30.2