From 6585e43eec0023702dfbcab68cd7163d49452714 Mon Sep 17 00:00:00 2001 From: Arthur Outhenin-Chalandre Date: Thu, 10 Sep 2020 02:57:04 +0200 Subject: [PATCH] Fix memory gauge in mixin with multiple pods Signed-off-by: Arthur Outhenin-Chalandre --- docs/node-mixin/dashboards/node.libsonnet | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/node-mixin/dashboards/node.libsonnet b/docs/node-mixin/dashboards/node.libsonnet index 78241ed9..07dd1886 100644 --- a/docs/node-mixin/dashboards/node.libsonnet +++ b/docs/node-mixin/dashboards/node.libsonnet @@ -75,14 +75,15 @@ local gauge = promgrafonnet.gauge; // TODO: It would be nicer to have a gauge that gets a 0-1 range and displays it as a percentage 0%-100%. // This needs to be added upstream in the promgrafonnet library and then changed here. + // NOTE: avg() is used to circumvent a label change caused by a node_exporter rollout. local memoryGauge = gauge.new( 'Memory Usage', ||| 100 - ( - node_memory_MemAvailable_bytes{%(nodeExporterSelector)s, instance="$instance"} + avg(node_memory_MemAvailable_bytes{%(nodeExporterSelector)s, instance="$instance"}) / - node_memory_MemTotal_bytes{%(nodeExporterSelector)s, instance="$instance"} + avg(node_memory_MemTotal_bytes{%(nodeExporterSelector)s, instance="$instance"}) * 100 ) ||| % $._config,