Skip to content

Commit 9ca2ed8

Browse files
committed
antennine.org: an-metrics: add coreutils-base64 as dependency
- Currently wget/uclient-fetch seems unable to authenticate against an nginx's auth_basic when doing POST requests. As a workaround for now, add the token generation in the script /usr/bin/prometheus-push - post wan_ipv4 only if differs from lan_ipv4 - move the label domain at the beginning after job, to ease any further segmentation
1 parent 4ac91f1 commit 9ca2ed8

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

antennine.org/an-metrics/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include $(TOPDIR)/rules.mk
22

33
PROFILE_DESCRIPTION:=Prometheus collectors and script to push to a pushgateway server
44
PROFILE_DEPENDS:=\
5+
+coreutils-base64 \
56
+prometheus-node-exporter-lua \
67
+prometheus-node-exporter-lua-openwrt \
78
+prometheus-node-exporter-lua-wifi \

antennine.org/an-metrics/root/usr/bin/prometheus-push

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,18 @@ domain=$(uci get lime-autogen.system.domain)
88
lan_ipv4=$(uci get network.lan.ipaddr)
99
wan_ipv4=$(ip -o route get to 4.2.2.2 | sed -n 's|.*src \([0-9.]\+\).*|\1|p')
1010
host=$(uci get system.@system[0].hostname)
11+
token="$(echo -n "$pushgateway_user:$pushgateway_password" | base64)"
1112

1213
prometheus-node-exporter-lua > "$metrics_file"
1314
wget -qO /dev/null \
14-
--post-file "$metrics_file" \
15-
--user "$pushgateway_user" \
16-
--password "$pushgateway_password" \
17-
https://${pushgateway_host}/metrics/job/remote_nodes/instance/${lan_ipv4}\
18-
/port/9090/host/${host}/domain/${domain}/wan/${wan_ipv4}
15+
--post-file "$metrics_file" \
16+
--header="Authorization: Basic $token" \
17+
https://${pushgateway_host}/metrics\
18+
/job/remote_nodes\
19+
/domain/${domain}\
20+
/instance/${lan_ipv4}\
21+
/port/9090\
22+
/host/${host}\
23+
$( [ $wan_ipv4 != $lan_ipv4 ] && echo "/wan/$wan_ipv4" )
1924

2025
rm "$metrics_file"

0 commit comments

Comments
 (0)