Skip to content

Commit 2c433cd

Browse files
authored
Fix and simplify checkmetrics make target (prometheus#1731)
The checkmetrics target currently uses promtool v2.5.0 which doesn't include many improvements done over the time. This change also simplifies the promtool installation, avoiding a temporary directory by extracting the file directly to the target destination. Signed-off-by: Tobias Schmidt <[email protected]>
1 parent 0253277 commit 2c433cd

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DOCKER_ARCHS ?= amd64 armv7 arm64 ppc64le s390x
1919

2020
include Makefile.common
2121

22-
PROMTOOL_VERSION ?= 2.5.0
22+
PROMTOOL_VERSION ?= 2.18.1
2323
PROMTOOL_URL ?= https://github.com/prometheus/prometheus/releases/download/v$(PROMTOOL_VERSION)/prometheus-$(PROMTOOL_VERSION).$(GO_BUILD_PLATFORM).tar.gz
2424
PROMTOOL ?= $(FIRST_GOPATH)/bin/promtool
2525

@@ -129,9 +129,5 @@ test-docker:
129129
promtool: $(PROMTOOL)
130130

131131
$(PROMTOOL):
132-
$(eval PROMTOOL_TMP := $(shell mktemp -d))
133-
curl -s -L $(PROMTOOL_URL) | tar -xvzf - -C $(PROMTOOL_TMP)
134132
mkdir -p $(FIRST_GOPATH)/bin
135-
cp $(PROMTOOL_TMP)/prometheus-$(PROMTOOL_VERSION).$(GO_BUILD_PLATFORM)/promtool $(FIRST_GOPATH)/bin/promtool
136-
rm -r $(PROMTOOL_TMP)
137-
133+
curl -fsS -L $(PROMTOOL_URL) | tar -xvzf - -C $(FIRST_GOPATH)/bin --no-anchored --strip 1 promtool

checkmetrics.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ if [[ ( -z "$1" ) || ( -z "$2" ) ]]; then
55
exit 1
66
fi
77

8-
# Only check node_exporter's metrics, as the Prometheus Go client currently
9-
# exposes a metric with a unit of microseconds. Once that is fixed, remove
10-
# this filter.
11-
lint=$($1 check metrics < $2 2>&1 | grep "node_")
8+
# Ignore known issues in auto-generated and network specific collectors.
9+
lint=$($1 check metrics < "$2" 2>&1 | grep -v -E "^node_(entropy|memory|netstat|wifi_station)_")
1210

13-
if [[ ! -z $lint ]]; then
11+
if [[ -n $lint ]]; then
1412
echo -e "Some Prometheus metrics do not follow best practices:\n"
1513
echo "$lint"
1614

1715
exit 1
18-
fi
16+
fi

0 commit comments

Comments
 (0)