Running Grafana Alloy on Alpine
At the time of writing Grafana Alloy doesn't have a musl build in it's releases. To let it run on alpine we first install the glibc compatibility layer:
$ apk add gcompat
Now grab the latest version and unzip
$ export ALLOY_VERSION=v1.6.1
$ wget https://github.com/grafana/alloy/releases/download/$ALLOY_VERSION/alloy-linux-amd64.zip
$ unzip alloy-linux-amd64.zip
$ mv ./alloy-linux-amd64 /usr/bin/alloy
Now we need to create the file /etc/init.d/alloy
with the following contents:
#!/sbin/openrc-run
supervisor=supervise-daemon
name="alloy"
description="Vendor-neutral programmable observability pipelines."
documentation="https://grafana.com/docs/alloy/"
command="/usr/bin/alloy"
command_args="run --storage.path=/var/lib/alloy /etc/alloy/config.alloy"
command_user="alloy"
directory="/var/lib/alloy"
pidfile="/run/${RC_SVCNAME}.pid"
depend() {
need net
after net
}
start_pre() {
checkpath -d -o alloy:alloy -m755 $directory
if [ -f /etc/conf.d/alloy ]; then
. /etc/conf.d/alloy
fi
}
reload() {
ebegin "Reloading $RC_SVCNAME"
kill -HUP $(cat /run/${RC_SVCNAME}.pid)
eend $?
}
Now we need to make sure that the file has the correct permissions and add an alloy user:
$ chmod +x /etc/init.d/alloy
$ useradd alloy
Next we create a config file for alloy: /etc/conf.d/alloy
# /etc/conf.d/alloy: config file for /etc/init.d/alloy
ALLOY_BIN=/usr/bin/alloy
CUSTOM_ARGS=""
Voila! Thanks to the helpful config files by Hav0k94