From 6695558652ce7a85d041dc5a315db9210463658b Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Mon, 2 Sep 2019 09:03:02 +0200 Subject: [PATCH] Fix apt.sh arch duplication (#1462) In some cases apt.sh could output duplicated arch values causing the following error: Aug 29 12:12:22 host123 prometheus-node-exporter[2235]: time="2019-08-29T12:12:22Z" level=error msg="error gathering metrics: [from Gatherer #2] collected metric \"apt_upgrades_pending\" { label: label: gauge: } was collected before with the same name and label values\n" source="log.go:172" Signed-off-by: Andrey Arapov --- text_collector_examples/apt.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text_collector_examples/apt.sh b/text_collector_examples/apt.sh index b78d38e00c..dcc44b3181 100755 --- a/text_collector_examples/apt.sh +++ b/text_collector_examples/apt.sh @@ -12,7 +12,7 @@ upgrades="$(/usr/bin/apt-get --just-print upgrade \ | /usr/bin/uniq -c \ | awk '{ gsub(/\\\\/, "\\\\", $2); gsub(/\"/, "\\\"", $2); gsub(/\[/, "", $3); gsub(/\]/, "", $3); - print "apt_upgrades_pending{origin=\"" $2 "\",arch=\"" $3 "\"} " $1}' + print "apt_upgrades_pending{origin=\"" $2 "\",arch=\"" $NF "\"} " $1}' )" echo '# HELP apt_upgrades_pending Apt package pending updates by origin.'