From ae58246f57ccea74a1fd9074b3b1d4807b83b5ac Mon Sep 17 00:00:00 2001 From: Dirk Heilig Date: Wed, 14 Aug 2024 16:42:53 +0200 Subject: [PATCH] ommit timestamp for now --- mqtt2prom/run | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mqtt2prom/run b/mqtt2prom/run index 97cd6c5..dff5ad7 100755 --- a/mqtt2prom/run +++ b/mqtt2prom/run @@ -216,7 +216,19 @@ function output(): void $prom .= "# $fkey in the last $fname: $count\n"; } } - foreach ($data as $entry) { + + $filteredData=[]; + + foreach($data as $entry){ + $sort=$entry['labels']??[]; + ksort($sort); + $sort[]=$entry['name']; + $hash=md5(json_encode($sort)); + $filteredData[$hash]=$entry; + } + + + foreach ($filteredData as $entry) { $labels = []; if (isset($entry["labels"])) { foreach ($entry["labels"] as $labelName => $labelValue) { @@ -238,8 +250,6 @@ function output(): void $labels . " " . $entry["value"] . - " " . - $entry["timestamp"] . "\n"; } file_put_contents("/www/metrics/new.prom", $prom);