Skip to content

aviate-labs/node-metrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Node Metrics

This document provides a detailed guide on how to set up and use node metrics for monitoring a node's performance. The metrics are collected by the node and can be accessed through its REST API. For a more comprehensive observability stack, refer to the official observability stack repository.

Prometheus

The node exposes a Prometheus endpoint for scraping metrics. Follow the steps below to install and configure Prometheus on your Ubuntu instance.

Prerequisites

  • A running instance of Ubuntu 22.04 LTS
  • Root or sudo privileges
  • Basic knowledge of the command line and Linux system administration

Installation

Step 1: Update the System

Before installing any new software, it's advisable to update your system with the latest packages. This ensures you have the most recent security patches and software updates.

sudo apt update && sudo apt upgrade -y

Step 2: Create a Prometheus User

For security reasons, Prometheus should not run as the root user. Create a dedicated user for Prometheus with restricted permissions.

sudo useradd --no-create-home --shell /bin/false prometheus

Step 3: Download Prometheus

Download the latest version of Prometheus from the official website. Replace the URL with the latest version if necessary. The example below uses version 2.45.5 LTS.

pushd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.45.5/prometheus-2.45.5.linux-amd64.tar.gz

Make sure to verify the integrity of the downloaded file using the sha256sum command. You can find the checksums on the download page.

sha256sum prometheus-2.45.5.linux-amd64.tar.gz 
tar xvf prometheus-2.45.5.linux-amd64.tar.gz
popd

Step 4: Configure Prometheus

Move the Prometheus binaries and configuration files to the appropriate directories and set the correct ownership to ensure Prometheus runs under the correct user.

sudo mv /tmp/prometheus-2.45.5.linux-amd64/prometheus /usr/local/bin/
sudo mv /tmp/prometheus-2.45.5.linux-amd64/prometheus.yml /etc/prometheus/prometheus.yml

sudo chown prometheus:prometheus /usr/local/bin/prometheus

sudo mkdir /var/lib/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus

You can now edit the Prometheus configuration file to scrape metrics from the node. You can find an example here.

sudo nano /etc/prometheus/prometheus.yml

Step 5: Create a Prometheus Service

Create a systemd service file to manage the Prometheus service. This file ensures Prometheus starts automatically on boot and can be controlled using the systemctl command.

sudo nano /etc/systemd/system/prometheus.service

Add the following content to the file:

[Unit]
Description=Prometheus Monitoring
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
    --config.file=/etc/prometheus/prometheus.yml \
    --storage.tsdb.path=/var/lib/prometheus/

[Install]
WantedBy=multi-user.target

Reload the systemd daemon to apply the changes and start the Prometheus service. Enable the service to start on boot.

sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus

Step 6: Verify Prometheus Installation

Ensure that Prometheus is running correctly by checking the status of the service.

sudo systemctl status prometheus

You should also be able to access the Prometheus web interface at http://localhost:9090 locally or http://<your-ip>:9090 from a remote machine.

IPv6 Connectivity

To access node metrics over IPv6, you need to enable IPv6 connectivity on your machine. Depending on your cloud provider, additional steps might be required to enable IPv6 on your instance ( e.g. Enable IPv6 on Digital Ocean Droplets).

This section provides a general guide on how to enable IPv6 on an Ubuntu instance. Refer to your cloud provider's documentation for specific instructions.

Enabling IPv6 on Ubuntu

Edit the /etc/netplan/50-cloud-init.yaml file to enable IPv6 connectivity. This file configures networking on your Ubuntu instance.

sudo nano /etc/netplan/50-cloud-init.yaml

Add or modify the configuration to include IPv6 settings, then apply the changes using:

sudo netplan apply

Following these steps, you will have a fully functioning Prometheus setup to monitor node metrics efficiently.

Generating a Prometheus Configuration

To generate a Prometheus configuration file, you can use the golang script provided in this repository. The script generates a configuration file based on a node provider identifier.

Generate a configuration file by running the following command:

go run main.go --node-provider-id="rbn2y-6vfsb-gv35j-4cyvy-pzbdu-e5aum-jzjg6-5b4n5-vuguf-ycubq-zae" --use-dashboard

The --use-dashboard flag is optional and generates a configuration file based on the node provider's dashboard. You can also run the script without the flag to generate a configuration file based on the registry what will be fetched from the main-net registry directly.

The --out flag can be used to specify the output file path. By default, the configuration file is saved in the current directory as prometheus.yml.

References