]> git.proxmox.com Git - pve-manager.git/commitdiff
fix #3440: influxdb: remove duplicate vmid tag
authorLorenz Stechauner <l.stechauner@proxmox.com>
Wed, 26 May 2021 09:25:11 +0000 (11:25 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 27 May 2021 10:32:04 +0000 (12:32 +0200)
remove vmid from data part, it is already contained in object part.
this is accomplished by adding the parameter $excluded to
build_influxdb_payload().

Signed-off-by: Lorenz Stechauner <l.stechauner@proxmox.com>
PVE/Status/InfluxDB.pm

index 9e4b0d966315b5c4d4e757d7a86dcef299f0093e..b2bd25d2eddb33947b7a76518a61a00db4e80289 100644 (file)
@@ -94,7 +94,8 @@ sub update_qemu_status {
     }
     $object =~ s/\s/\\ /g;
 
-    build_influxdb_payload($class, $txn, $data, $ctime, $object);
+    # Duplicate keys may result in unwanted behavior
+    build_influxdb_payload($class, $txn, $data, $ctime, $object, { 'vmid' => 1 });
 }
 
 sub update_lxc_status {
@@ -108,7 +109,8 @@ sub update_lxc_status {
     }
     $object =~ s/\s/\\ /g;
 
-    build_influxdb_payload($class, $txn, $data, $ctime, $object);
+    # Duplicate keys may result in unwanted behavior
+    build_influxdb_payload($class, $txn, $data, $ctime, $object, { 'vmid' => 1 });
 }
 
 sub update_storage_status {
@@ -246,11 +248,12 @@ sub test_connection {
 }
 
 sub build_influxdb_payload {
-    my ($class, $txn, $data, $ctime, $tags, $measurement, $instance) = @_;
+    my ($class, $txn, $data, $ctime, $tags, $excluded, $measurement, $instance) = @_;
 
     my @values = ();
 
     foreach my $key (sort keys %$data) {
+       next if defined($excluded) && $excluded->{$key};
        my $value = $data->{$key};
        next if !defined($value);
 
@@ -264,9 +267,9 @@ sub build_influxdb_payload {
            # value is a hash
 
            if (!defined($measurement)) {
-               build_influxdb_payload($class, $txn, $value, $ctime, $tags, $key);
+               build_influxdb_payload($class, $txn, $value, $ctime, $tags, $excluded, $key);
            } elsif(!defined($instance)) {
-               build_influxdb_payload($class, $txn, $value, $ctime, $tags, $measurement, $key);
+               build_influxdb_payload($class, $txn, $value, $ctime, $tags, $excluded, $measurement, $key);
            } else {
                push @values, get_recursive_values($value);
            }