Skip to content

fpatron/tig-dashboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Innovation Game Dashboard

This project allows you to monitor your TIG nodes directly in Grafana, providing the necessary information and facilitating tracking.

https://github.com/tig-foundation/tig-monorepo

Prerequisites

Depending on your setup, you can use Docker or a manual setup to install this dashboard.

You need:

  • A Grafana server running 24/7
  • A server to retrieve TIG data running 24/7 (can be the same as the Grafana server)

It is preferable to have your own Grafana server for monitoring your nodes. But you can use Grafana Cloud which will provide you with the necessary stack https://grafana.com/

Quick start

You can quickly install this dashboard using Docker. If you don't want to use Docker, follow the manual instructions.

First, install Docker:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Case #1: you don't have a grafana server

  1. Prepare your environment
mkdir tig-dashboard
cd tig-dashboard
  1. Create a settings file called settings.env with these parameters inside:
PLAYER_IDS='["a","b","d","d"]'
INNOVATOR_IDS='["e"]'
  • PLAYER_IDS: list of your benchmarker addresses
  • INNOVATOR_IDS: list of your innovator addresses
  1. Install and run docker image
bash <(wget -qO- https://raw.githubusercontent.com/fpatron/tig-dashboard/master/docker/install_allinone.sh)
sudo docker compose --env-file ./settings.env -f docker-compose-allinone.yml build
sudo docker compose -f docker-compose-allinone.yml up -d

Case #2: you have a grafana server

  1. Prepare your environment
mkdir tig-dashboard
cd tig-dashboard
  1. Create a settings file called settings.env with these parameters inside:
PROMETHEUS_URL=http://0.0.0.0:9090/api/v1/write
PLAYER_IDS='["a","b","d","d"]'
INNOVATOR_IDS='["e"]'
  • PROMETHEUS_URL: url of your grafana server (ie: PROMETHEUS_URL=http://192.168.0.100:9090/api/v1/write)
  • PLAYER_IDS: list of your benchmarker addresses
  • INNOVATOR_IDS: list of your innovator addresses
  1. Install and run docker image
bash <(wget -qO- https://raw.githubusercontent.com/fpatron/tig-dashboard/master/docker/install_exporter.sh)
sudo docker compose --env-file ./settings.env -f docker-compose-exporter.yml build
sudo docker compose -f docker-compose-exporter.yml up -d

Finalize setup

You can now connect to your Grafana server using the IP address of the server where you installed it.

http://X.X.X.X:3000

The default login and password are admin/admin.

Now, import the Grafana dashboard by following the instructions here.

Manual installation

Step #1: installing Grafana / Victoria Metrics

You have multiple choices to create your Grafana instance:

  • Use Grafana Cloud: they provided a limited free plan
  • Use the provided Docker image to create your own Grafana instance
  • Use a dedidcated VM
  1. Install Docker (see above)
  2. Install Docker image
cd
mkdir grafana
cd grafana
wget https://github.com/fpatron/tig-dashboard/blob/master/docker/docker-compose-grafana.yml
sudo docker compose up -d

Step #2: installing TIG data exporter

It is necessary to install the custom exporter in order to send custom metrics to grafana:

  • Create a directory tig_exporter on your server
mkdir -p ~/tig_exporter
cd ~/tig_exporter
wget https://raw.githubusercontent.com/fpatron/tig-dashboard/master/exporter/tig_exporter.py
wget https://raw.githubusercontent.com/fpatron/tig-dashboard/master/exporter/requirements.txt
  • Setup exporter script

Replace the variables PLAYER_IDS and INNOVATOR_IDS with your TIG addresses. You can leave the PLAYER_IDS or INNOVATOR_IDS vars empty according to your setup.

Example:

PLAYER_IDS = ["0x73C7A2e1C9eb014EDbad892487D4cd4FEc5B239f","0x73C7A2e1C9eb014EDbad892487D4cd4FEc5B239f"]
INNOVATOR_IDS = []
  • Prepare python environment
sudo apt install python3 python3-pip python3-virtualenv
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
sudo nano /lib/systemd/system/tig_exporter.service
[Unit]
Description=TIG Exporter Service
After=network.target

[Service]
User=<your_username>
Group=<your_username>
WorkingDirectory=/home/<your_username>/tig_exporter
ExecStart=/home/<your_username>/tig_exporter/venv/bin/python /home/<your_username>/tig_exporter/tig_exporter.py
Restart=always

[Install]
WantedBy=multi-user.target

Replace the <your_username> values and paths if needed with the correct values.

  • Enable the service:
sudo systemctl daemon-reload
sudo systemctl enable tig_exporter
sudo systemctl start tig_exporter

To test if the TIG exporter is working, run this command:

curl http://127.0.0.1:5002/metrics

Step #3: Installing Grafana Alloy

It is necessary to install the Grafana Alloy agent on your server. It will be responsible for reporting your TIG metrics.

To install it, run these commands:

wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null                              
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt-get install alloy -y

Step #4: Configuring Grafana Alloy

Once the agent is installed, you need to configure it. The configuration file is located here:

/etc/alloy/config.alloy

Delete its contents and replace them with the contents of the example file config.alloy

Replace the following tags with your own information:

  • <PROMETHEUS_ENDPOINT> (eg: http://X.X.X.X:9090/api/v1/write)
  • <PROMETHEUS_USERNAME> (optional, leave empty or remove it)
  • <PROMETHEUS_PASSWORD> (optional, leave empty or remove it)

If you use the Grafana Cloud suite, you will need to generate an API key for Prometheus. Replace the Prometheus password with this key.

Restart alloy

sudo systemctl daemon-reload
sudo systemctl restart alloy

Importing the Dashboard

Go to your Grafana instance (http://X.X.X.X:3000) and log into (admin/admin)

  1. Import the dashboard
    • Go to Home > Dashboard
    • Download the dashboard in JSON format
    • Click on the "New" > "Import" button
    • Upload the dashboard in JSON format
    • Select the requested datasources

Once everything is set up, wait at least 30 minutes to get good metrics on your dashboard :)

After the initial installation, wait at least 24 hours to obtain reliable metrics.

That's all! Enjoy!

Note: in some cases, you have to setup datasources:

  1. Install the Infinity plugin
    • Go to Home > Administration > Plugins and data > Plugins
    • Search for the Infinity plugin and install it

By default, only installed plugins are displayed. Switch to "All" mode (top right).

  1. Add datasources
    • Go to Home > Data sources
    • Click on the "Add new data sources" button
    • Search for "Infinity"
    • Click on "Save & test"
    • Click on the "Add new data sources" button
    • Search for "Prometheus"
    • Connection : Prometheus URL : http://192.168.X.X:9090 (put the IP of the computer running docker)
    • Click on "Save & test"

How to update your TIG exporter

Docker update

Depending on whether you use case #1 or case #2 installation, use the correct Docker Compose file

  • case #1: docker-compose-allinone.yml
  • case #2: docker-compose-exporter.yml
cd tig-dashboard
sudo docker stop $(docker ps -aq)
sudo docker compose --env-file ./settings.env -f <to be replace with docker compose file> build
sudo docker compose -f <to be replace with docker compose file> up -d

Manual update

In case of manual installation

cd ~/tig_exporter
wget https://raw.githubusercontent.com/fpatron/tig-dashboard/master/exporter/tig_exporter.py -O tig_exporter.new
wget https://raw.githubusercontent.com/fpatron/tig-dashboard/master/exporter/requirements.txt

Replace the variables PLAYER_IDS and INNOVATOR_IDS with your TIG addresses in tig_exporter.new file.

  • Replace python script
mv tig_exporter.new tig_exporter.py
  • Update python environment
source venv/bin/activate
pip install -r requirements.txt
  • Restart the service:
sudo systemctl restart tig_exporter

Donations

You can support our work by making a donation to this TIG address: 0x73C7A2e1C9eb014EDbad892487D4cd4FEc5B239f

Thanks!

About

Grafana dashboard designed for The Innovation Game

Resources

License

Stars

Watchers

Forks