File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description =Update the prometheus static file config based off of PushProx
3
+
4
+ [Service]
5
+ User =pushprox-updater
6
+ Group =pushprox-updater
7
+
8
+ EnvironmentFile =-/etc/default/pushprox-updater
9
+ ExecStart =/usr/bin/pushprox-updater
10
+
11
+ NoNewPrivileges =true
12
+ PrivateTmp =yes
13
+ PrivateDevices =true
Original file line number Diff line number Diff line change
1
+ [Unit]
2
+ Description=Update the prometheus static file config based off of PushProx
3
+
4
+ [Timer]
5
+ OnStartupSec=20s
6
+ OnUnitInactiveSec=20s
7
+
8
+ [Install]
9
+ WantedBy=timers.target
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ host=${PUSHPROX_HOST:- localhost: 8080}
6
+ ports=${PUSHPROXY_PORTS:- 9100}
7
+ sd_file=${PUSHPROXY_FILE:-/ etc/ prometheus/ file_sd/ clients.json}
8
+
9
+ tmpfile=$( mktemp --suffix " pushprox-target-updater" )
10
+ trap ' rm -f "$tmpfile"' EXIT
11
+
12
+ if ! curl -s " $host /clients" | jq --argjson ports " [$ports ]" '
13
+ . | map(.targets[0] as $target | {
14
+ targets: $ports | map(tostring) | map($target + ":" + .)
15
+ })' > " $tmpfile " ; then
16
+ echo >&2 " Failed to update inventory"
17
+ exit 2
18
+ fi
19
+
20
+ chmod a+r " $tmpfile "
21
+ mv " $tmpfile " " $sd_file "
You can’t perform that action at this time.
0 commit comments