How To Install & Configure HalfLife To Monitor Your Cosmos Validator
In this how to, I will cover how to build/install and configure The Halflife Monitoring Tool made by Strangelove Ventures.
You can find the github repository here: https://github.com/strangelove-ventures/half-life
Step 1: Create a user for the service
adduser --gecos "" --disabled-password halflife
chpasswd <<<halflife:$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c24)
This will create a 24-character random password for the user. Because we never expect that this user should be allowed to login, it doesn’t matter if we know the password. Root can su to halflife without a password. This should be all you need to use to access this user.
Step 2: Install go and set the paths
Install Go:
GOVER=$(curl https://go.dev/VERSION?m=text)
wget https://golang.org/dl/${GOVER}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf ${GOVER}.linux-amd64.tar.gz
Add the proper paths to the halflife users .profile
# add environmental variables for Go
if [ -f "/usr/local/go/bin/go" ] ; then
export GOROOT=/usr/local/go
export GOPATH=${HOME}/go
export GOBIN=$GOPATH/bin
export PATH=${PATH}:${GOROOT}/bin:${GOBIN}
fi
Step 3: Clone the github directory.
git clone https://github.com/effofxprime/half-life.git
cd half-life
go install
This will install it to ~/go/bin
Step 4: Configure HalfLife
notifications:
service: discord
discord:
webhook:
id: "TOKEN ID"
token: TOKEN
alert-user-ids:
- "YOUR DISCORD USER ID"
username: HalfLife
validators:
- name: Aura
rpc: https://snapshot-1.euphoria.aura.network:443
fullnode: false
address: YOUR VALIDATOR VALCONS ADDRESS
chain-id: euphoria-1
rpc-retries: null
missed-blocks-threshold: null
sentries: null
- name: Vidulum
rpc: https://trpc.rpc.erialos.me:26657
fullnode: false
address: YOUR VALIDATOR VALCONS ADDRESS
chain-id: vidulum-1
rpc-retries: null
missed-blocks-threshold: null
sentries: null
In my example configuration shown above, I have shown how to monitor more than one validator. Continue to add sections in the same format for each additional Validattor/Fullnode/Sentry you are monitoring.
First you will want to create a new channel in your Discord Server. Then create your webhook as instructed here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
You will want to name it the same as the username
field. That field defines the name of the bot. Then select the new channel you just made for this webhook.
Save!
Copy the URL.
The url will look like this format
https://discord.com/api/webhooks/978129125394247720/cwM4Ks-kWcK3Jsg4I_cboauYjOa48ngI2VKaS76afsMwuY7-U4Frw3BGcYXCJvZJ2kWD
The corresponding id and token can be taken from the url.
id: 978129125394247720
token: cwM4Ks-kWcK3Jsg4I_cboauYjOa48ngI2VKaS76afsMwuY7-U4Frw3BGcYXCJvZJ2kWD
You will need to find out your User ID, or all user id’s you want to be alerted if a high/critical error is reached. Follow this guide to enable it and learn how to get them: https://support.discord.com/hc/en-us/articles/206346498-Where-can-I-find-my-User-Server-Message-ID-
An example configuration with the above information and alerting two users:
notifications:
service: discord
discord:
webhook:
id: "TOKEN ID"
token: TOKEN
alert-user-ids:
- "YOUR DISCORD USER ID"
- "A SECOND DISCORD USER ID"
username: HalfLife
Here is a link to the example configuration for further study. You will see that there are more options to enable or configure based on your setup.
https://github.com/strangelove-ventures/half-life/blob/main/config.yaml.example
Step 6: Create Service File
nano /etc/systemd/system/halflife.service
Add this to the service file, save, and quit
[Unit]
Description=HalfLife Validator Monitor
After=network.target[Service]
Group=halflife
User=halflife
WorkingDirectory=/home/halflife
ExecStart=/home/halflife/go/bin/halflife monitor -f /home/halflife/.halflife/personal_validators.yaml
Restart=on-failure
RestartSec=3
LimitNOFILE=8192[Install]
WantedBy=multi-user.target
Regarding the ExecStart
line in the service file. I created a directory .halflife
and named the configuration file personal_validators.yaml
and so I have to specify it for HalfLife to read the configuration.
Change this to fit your own needs, and where you decide to place your configuration file.
Lastly update the systemd service:
systemctl daemon-reload && systemctl enable halflife
Step 5: Start and View the logs.
systemctl start halflife && journalctl -u halflife -f
You should see updates in your Discord channel and the journal log should scroll that it is Monitoring NAME
where name is the name of the chain that you specified in the configuration.
I hope you found this helpful!