Prometheus and Grafana
The Bifrost node and relayer also supports system metric monitoring. This guide will walk you through how to setup Prometheus and Grafana to monitor your node and relayer.
Enable Prometheus
In order to let your Bifrost node and relayer to collect Prometheus metrics, it must be manually enabled. To enable the Prometheus server of your node, the following CLI flags has to be provided and then restarted.
--prometheus-external
: This exposes the Prometheus exporter on all interfaces.--prometheus-port <PORT>
: The default port will be set to9615
. However, if port changes are required, then this flag must be provided.
In case that you're operating a full-node, to enable the Prometheus server of your relayer, the following parameters of your configuration YAML file has to be updated as below and restarted.
If it has been successfully restarted, in both of your services the following log will be printed at the initial launch.
Using Systemd
This section contains how to install and setup Prometheus and Grafana by using Systemd.
Installing Prometheus
First, create the directories required to store the configuration and executable files.
Then, update your OS and install the latest Prometheus. You can check the latest releases by going to their GitHub repository under the releases page.
Copy the executable files to the /usr/local/bin/
directory.
Copy the console files to the /etc/prometheus
directory.
Once everything is done, remove the prometheus
directory.
Installing NodeExporter
Now, install the NodeExporter. You can check the latest releases by going to their Github repository under the releases page.
Installing AlertManager
First, create the directories required to store the configuration and executable files.
Next, install the AlertManager. You can check the latest releases by going to their Github repository under the releases page.
Install the AlertManager plugins required for Grafana.
Configure Alert Rules
Create the rules.yml
file that will give the rules for the AlertManager.
We are going to create 2 basic rules that will trigger an alert in case the instance is down or the CPU usage crosses 80%. Add the following lines and save the file.
The alertmanager.yml
file is used to set the external service that will be called when an alert is triggered. Here, we are going to use the Gmail notification.
For Gmail notification, you will need to generate an app password. We recommend you to use a dedicated email address for your alerts. In order to set-up follow this link.
Create the file in the following path.
And add the Gmail configuration to it and save the file as below.
Configure Prometheus
In order to start Prometheus, it needs some configuration. Create a configuration yaml file in the following directory.
The configuration file should look as below.
Starting Prometheus
Next, the Systemd configuration should be set for Prometheus. Create a configuration file in the following directory.
The configuration file should look as below.
Now, enable and start the service.
To test out if it all successfully worked, access YOUR_SERVER_IP_ADDRESS:9090
. If the Prometheus dashboard appears, it is good to go.
Starting NodeExporter
The Systemd configuration should be set for the NodeExporter. Crate a configuration file in the following directory.
The configuration file should look as below.
Now, enable and start the service.
Starting AlertManager
The Systemd configuration should be set for the AlertManager. Crate a configuration file in the following directory.
The configuration file should look as below.
Now, enable and start the service.
Installing Grafana
To visualize your Prometheus metrics, you should install Grafana, which queries the Prometheus server. The latest releases can be checked on their download page. Execute the following commands to install the necessary dependencies.
Starting Grafana
Then enable and start the service with default configurations.
You can now access it by going to YOUR_SERVER_IP_ADDRESS:3000/login
. The default user and password is admin/admin
.
Using Docker
This section contains how to install and setup Prometheus and Grafana by using Docker.
Requirements
First, Docker and Docker Compose should be installed in your server. Then you can download the docker-compose.yml
file that is provided in Bifrost node's Github repository. Download the file by using the command below. The file will be located in the maintenance
directory.
Configure AlertManager
The alert rules are pre-defined in the maintenance/prometheus/rules.yml
file. It contains 2 basic rules that will trigger an alert in case the instance is down or the CPU usage crosses 80%. The file will be provided as below.
The alertmanager.yml
file is used to set the external service that will be called when an alert is triggered. Here, we are going to use the Gmail notification.
For Gmail notification, you will need to generate an app password. We recommend you to use a dedicated email address for your alerts. In order to set-up follow this link.
The file locates in the maintenance/alertmanager/alertmanager.yml
directory. Then, add the Gmail configuration to it and save the file as below.
Configure Prometheus
In order to start Prometheus, it needs some configuration. The configuration file locates at maintenance/prometheus/prometheus.yml
. For Full-Node operators who runs the node and relayer both, should manually uncomment the below "relayer" job.
Run Docker Containers
If you have followed every processes above, return to the maintenance
directory and execute the following command.
You can now access it by going to YOUR_SERVER_IP_ADDRESS:3000/login
. The default user and password is admin/admin
.
Datasource Configuration
If it is all set, create a new Prometheus datasource and input the URL
as http://localhost:9090
and then click “Save & Test” as below.
For Docker users, the URL should be set to http://prometheus:9090
.
Then, create a new Prometheus AlertManager datasource and input the URL as http://localhost:9093
and then click "Save & Test" as below.
For Docker users, the URL should be set to http://alertmanager:9093
.
Next, the dashboard has to be imported. Access the "Dashboards" tab and click on "New" to import the dashboard as below.
Now, in the "Import via grafana.com" section, input the dashboard ID as 19207
and then click "Load" to continue.
If it has been successfully loaded, set the correct datasources that you have just created before. The Prometheus and the AlertManager has to be set correctly. Then click "Import" to continue.
In the meantime, if your node and relayer is running in the background, the collected metrics will be visualized as below.
Last updated