# Monitoring

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FeduGyMqhmqWMgasPS6jW%2Fmoni.jpg?alt=media&#x26;token=cd195cdc-0549-4251-922c-adc21b7c7340" alt=""><figcaption></figcaption></figure>

## &#x20;               TenderDuty v2 - monitoring and alerting

## Tenderduty is a comprehensive monitoring tool for Tendermint networks. More details can be found [here ](https://github.com/blockpane/tenderduty)

This TenderDuty v2 monitoring allows you to study control over nodes and, in particular, see the height of the network, validator status, uptime, signed and passed blocks. It is also possible to connect alerts to Telegram and Discord. Installation is possible in different ways, but I will use installation via Docker, although there are no fundamental differences. So, we will need a separate server (which definitely provides additional security) or a server with node(s) already installed. You will also need to find an open RPC or open your primary (not recommended) or backup node.

### [You can evaluate the work of the process using our nodes as an example](https://monitoring.stavr.tech/)

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FOKgUCbUJRIghRxocvOU3%2FTender.png?alt=media&#x26;token=63942bdd-91a1-43d4-bf28-e8f2a968ea68" alt=""><figcaption></figcaption></figure>

```bash
# updating repositories
sudo apt update && sudo apt upgrade -y

# install the necessary utilities
sudo apt install curl build-essential git wget jq make gcc tmux htop nvme-cli pkg-config libssl-dev libleveldb-dev tar clang bsdmainutils ncdu unzip libleveldb-dev -y
```

**Installing Docker**

```bash
apt update &&
apt install apt-transport-https ca-certificates curl software-properties-common -y &&
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &&
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" &&
apt update &&
apt-cache policy docker-ce &&
sudo apt install docker-ce -y &&
docker --version
```

**Install tenderduty**

```bash
tmux new-session -s tenderduty

mkdir tenderduty && cd tenderduty
docker run --rm ghcr.io/blockpane/tenderduty:latest -example-config >config.yml
```

**Download the config and edit it**

```bash
wget -O $HOME/tenderduty/config.yml "https://raw.githubusercontent.com/111STAVR111/props/main/Tenderduty/config.yml"
nano $HOME/tenderduty/config.yml
```

`For simple monitoring without alerts, just change in the config:`

* network name:&#x20;
* chain-id:&#x20;
* valoper\_address:&#x20;
* url:&#x20;

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FU9tNsegRsQhqdUvbTRQZ%2Fconfig.png?alt=media&#x26;token=e1646814-2de5-4697-8c5b-456af50e1471" alt=""><figcaption></figcaption></figure>

**After installing and editing the config, run docker**

```bash
docker run -d --name tenderduty -p "8888:8888" -p "28686:28686" --restart unless-stopped -v $(pwd)/config.yml:/var/lib/tenderduty/config.yml ghcr.io/blockpane/tenderduty:latest

# logs
docker logs -f --tail 20 tenderduty
```

**Checking our work in the browser**

```bash
# find out the address and paste it into the browser
echo -e "\033[0;32mhttp://$(wget -qO- eth0.me):8888/\033[0m"
# http://55.18.19.38:8888/
```

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FsEM85AhLaXYanoDtBI39%2FTender.png?alt=media&#x26;token=4347f1f8-3c84-4d9b-96cd-b60e2f6172dc" alt=""><figcaption></figcaption></figure>

## &#x20;                                      Setting up alerts in Discord

It's pretty easy to turn on an alert for discord. To do this you only need to perform a few steps

Let's go to our config and paste this link into the Webhook section

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FWJpfw8yl5IILpnkV3cRD%2F1.png?alt=media&#x26;token=fe4c7358-9ef3-4593-a38d-36a6fa4d6418" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FJvZVywtwkq8IieSYZpAu%2F2.png?alt=media&#x26;token=4c5f953f-549a-4969-9e67-c0bb4a33edf9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FQYK5ZFAmLTG6HrXwM4A6%2F3.png?alt=media&#x26;token=6b6ec938-7ba1-488b-9d6d-266b96336a22" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FbZcopbpen2QwgODl2lOv%2F4.png?alt=media&#x26;token=34116a70-327b-4f19-bdc7-cfa34967a3a0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FovCuD1p05xIc9qr0V3BE%2F5.png?alt=media&#x26;token=1c37776e-b6ad-4f9b-bbdb-3b8259e77a4c" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FV2ej8DAtuJYfp56iH8Fe%2F6.png?alt=media&#x26;token=6c99f131-3d35-4efd-8efd-a2a7521d4837" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FTALnt9stWGa9h8IYUs9T%2F7.png?alt=media&#x26;token=90d592f6-3e2d-4e51-97e5-2c8da0fe58a3" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2Fmp1rhMA4YnITrQHRArkI%2F8.png?alt=media&#x26;token=0b39a3ac-680b-4814-a969-062b79488a7e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FxjtGE20WhwEfW81W79po%2F9.png?alt=media&#x26;token=61565359-ad8d-46d9-b95a-c7448aaf9596" alt=""><figcaption></figcaption></figure>

Let's go to our config and paste this link into the Webhook section

```bash
$HOME/tenderduty/config.yml
```

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FKAzmUsFJ1cGngifleJkI%2F10.png?alt=media&#x26;token=6ac0f29b-dbf8-4f1a-b167-7ade924f632a" alt=""><figcaption></figcaption></figure>

Reboot our Tenderduty - and now everything should be displayed in discord

`docker restart tenderduty`

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FEQ8eDe6K6IYDh7UbzJ5s%2F11.png?alt=media&#x26;token=b74bcb48-53e0-4c4e-b3db-028a65422c4d" alt=""><figcaption></figcaption></figure>

## &#x20;                        Setting up alerts in Telegram

Telegram takes a little longer to set up, but overall it's not very difficult. We will need to create our own bot and find out the ID of our telegram or the ID of the group we need in telegram

* Create your own bot. To do this, write to the bot **@BotFather** and enter the command /newbot - then enter the bot name - then username (<mark style="color:yellow;">must end with</mark> <mark style="color:yellow;"></mark><mark style="color:yellow;">**bot**</mark>). The bot will issue an API token, which we securely <mark style="color:red;">save and do not show to anyone</mark>

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FaO19Tq139KZiR73jChKn%2F1.png?alt=media&#x26;token=14dfa436-a514-4f48-86d4-147a8ff0b5a2" alt=""><figcaption></figcaption></figure>

* Find out your ID or group ID (to do this, add the bot to the group). To find out your ID, write to the bot @JsonViewBot and send it any message

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FZPfK6hCYoeytl6ZwfhFZ%2F2.png?alt=media&#x26;token=ffdea7ea-ab08-4c95-8c3d-f71ad4b1f9d6" alt=""><figcaption></figcaption></figure>

* Now it's time to add the **ID** and **Token** **API** to our configuration, then restart monitoring and wait for future alerts.

<figure><img src="https://2850165036-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FaJyfwvlEgVMyUPbcpkk6%2Fuploads%2FYW2FNgkvqNurTCusbAaX%2F3.png?alt=media&#x26;token=8d27ac57-1750-4b20-94c9-6da68ca6bf73" alt=""><figcaption></figcaption></figure>

## **Useful commands**

```bash
# view installed images
docker images
# view activated containers
docker ps
# stop container
docker stop tenderduty
# restart container
docker restart tenderduty
# logs
docker logs -f --tail 20 tenderduty
```

```bash
# find out the RPC nodes for the config
NODE_FOLDER=".lava"
echo -e "\033[0;32mhttp://$(wget -qO- eth0.me)$(grep -A 3 "\[rpc\]" ~/$NODE_FOLDER/config/config.toml | egrep -o ":[0-9]+")\033[0m"
```
