From dcddb174cb66c9fc37d2ad6bb3294c5cb57a7719 Mon Sep 17 00:00:00 2001 From: Yossi Ioukhtov Date: Mon, 8 Jul 2024 11:02:00 +0300 Subject: [PATCH] skip metrics with an empty samples list --- src/clients/prometheus.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/clients/prometheus.js b/src/clients/prometheus.js index 23b342c..9b1e5e4 100644 --- a/src/clients/prometheus.js +++ b/src/clients/prometheus.js @@ -19,6 +19,13 @@ class Prometheus { throw new QrynError('Metrics must be an array of Metric instances'); } + metrics = metrics.filter((m)=>{ + if(m.samples.length === 0){ + console.log(`Skipping ${m.name} due to empty samples...`) + return false; + } else return true + }); + const timeseries = metrics.map(metric => metric.collect()); const writeRequest = { timeseries };