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 C086E6480B for ; Fri, 28 Jan 2022 11:08:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B5B102D04E for ; Fri, 28 Jan 2022 11:08:42 +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 F364C2D043 for ; Fri, 28 Jan 2022 11:08:41 +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 C5EF746CDC for ; Fri, 28 Jan 2022 11:08:41 +0100 (CET) Message-ID: <907ef603-4642-c377-195b-51d4dc6655dc@proxmox.com> Date: Fri, 28 Jan 2022 11:08:40 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-US From: Markus Frank To: pve-devel@lists.proxmox.com Reply-To: Proxmox VE development discussion References: <20220128100339.21230-1-m.frank@proxmox.com> In-Reply-To: <20220128100339.21230-1-m.frank@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.004 Adjusted score from AWL reputation of From: address 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 NICE_REPLY_A -0.001 Looks like a legit reply (A) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [influxdb.pm, influxdata.com] Subject: Re: [pve-devel] [PATCH manager v3] 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: Fri, 28 Jan 2022 10:08:42 -0000 manager not container On 1/28/22 11:03, Markus Frank wrote: > 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 $to_quote hashmap to define which value > shouldn't get interpreted as number. > In this case the value of name. > > Change: Conversion happends in prepare_value. > > 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 | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/PVE/Status/InfluxDB.pm b/PVE/Status/InfluxDB.pm > index def7e2fd..63a865df 100644 > --- a/PVE/Status/InfluxDB.pm > +++ b/PVE/Status/InfluxDB.pm > @@ -276,6 +276,8 @@ sub test_connection { > sub build_influxdb_payload { > my ($class, $txn, $data, $ctime, $tags, $excluded, $measurement, $instance) = @_; > > + # 'abc' and '123' are both valid hostnames, that confuses influx's type detection > + my $to_quote = { name => 1 }; > my @values = (); > > foreach my $key (sort keys %$data) { > @@ -286,7 +288,7 @@ sub build_influxdb_payload { > if (!ref($value) && $value ne '') { > # value is scalar > > - if (defined(my $v = prepare_value($value))) { > + if (defined(my $v = prepare_value($value, $to_quote->{$key}))) { > push @values, "$key=$v"; > } > } elsif (ref($value) eq 'HASH') { > @@ -331,9 +333,10 @@ sub get_recursive_values { > } > > sub prepare_value { > - my ($value) = @_; > + my ($value, $quote) = @_; > > - if (looks_like_number($value)) { > + # don't treat value like a number if quote is 1 > + if (looks_like_number($value) && !$quote) { > if (isnan($value) || isinf($value)) { > # we cannot send influxdb NaN or Inf > return undef;