# Setup

To be able to monitor your node through the Diagnostic Tool you must connect them.

The step needed to connect are:

1. [Run your Erigon node](#id-1.-run-your-erigon-node)
2. [Run the Diagnostic Tool](#id-2.-run-the-diagnostic-tool)
3. [Create a new session in the Diagnostic Tool](#id-3.-create-a-new-session-in-the-diagnostic-tool)
4. [Connect the Diagnostic Tool to your node](#id-4.-connect-the-diagnostic-tool-to-your-node)
5. [Refresh the Diagnostic Tool](#id-5.-refresh-the-diagnostic-tool)

## 1. Run your Erigon node

If you are not sure what to run, start from a test-net with [Caplin](https://docs.erigon.tech/erigon/v2/advanced-usage/consensus-layer/caplin) as the Consensus Engine.&#x20;

```
./build/bin/erigon --chain=holesky
```

## 2. Run the Diagnostic Tool

Run the Diagnostic Tool application from the machine where you intend to monitor your node.

```bash
cd diagnostics
make run-self-signed
```

{% hint style="info" %}
Starting up the application may take a while.&#x20;

More options can be found [here](https://github.com/ledgerwatch/erigon/tree/main/cmd/diag#diagnostics-commands).
{% endhint %}

The Diagnostic Tool page will automatically open in your browser at the address <http://localhost:8080>.

<figure><img src="https://2414554083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Feeqc6D5KqkgOsOW7j4k6%2Fuploads%2FNzyz3CnIYJxEPv0BemZn%2Fimage.png?alt=media&#x26;token=31d8c7d2-826d-4de0-bf32-edf27d9c1ac4" alt=""><figcaption><p>The Diagnostic Tool web-page</p></figcaption></figure>

{% hint style="warning" %}
Leaving the terminal session will close the Diagnostic Tool interface.
{% endhint %}

## 3. Create a new session in the Diagnostic Tool

The Diagnostic Tool is now operational, but to access the data, it must be integrated with the Erigon node. Proceed to the **Admin** section in the left navigation menu and select **Create Session**. Assign a name to your session and click **Create** to proceed.

{% embed url="<https://webm.red/rlbM>" %}
Creating a new session in Erigon Diagnostic Tool
{% endembed %}

Upon successful creation of a new session, it will be allocated a unique 8-digit code which will be YOUR\_SESSION\_PIN. You can locate this **PIN** displayed adjacent to the session in the list of created sessions.

Click on the copy button to copy the session ID to your clipboard&#x20;

<figure><img src="https://2414554083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Feeqc6D5KqkgOsOW7j4k6%2Fuploads%2FgQZc3mRjTF9GHqrFHFuq%2Fimage.png?alt=media&#x26;token=f251289c-27a3-4e90-8817-dcb97801e465" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
At this time it is possible to create only a single session. However, support for multiple concurrent sessions will be added in the future.
{% endhint %}

## 4. Connect the Diagnostic Tool to your node

{% tabs %}
{% tab title="Local Node" %}
If your Erigon node is running on your local machine, open a new console window in the Erigon folder and run the following command:

{% code overflow="wrap" %}

```bash
./build/bin/erigon support --diagnostics.sessions YOUR_SESSION_PIN
```

{% endcode %}

Replace `YOUR_SESSION_PIN` with the 8-digit PIN allocated to your session during the previous step, for example:

`./build/bin/erigon support diagnostics.sessions 15498880`

This command will attach the Diagnostics Tool to the Erigon node using the provided session pin.
{% endtab %}

{% tab title="Remote Node" %}
If your Erigon node is running on a **Virtual Private Server** (VPS) such as **Amazon AWS**, you can connect the Diagnostic Tool on your local machine with [ngrok](https://ngrok.com/docs/getting-started/) utility.

{% hint style="info" %}
**ngrok** was chosen because of its easy of use and because the free version is useful for our scope. It is possible to use any other similar tool.
{% endhint %}

1. You can run **ngrok** on your local machine in order to tunnel `localhost:8080`&#x20;

<pre class="language-bash"><code class="lang-bash"><strong>ngrok http http://localhost:8080
</strong></code></pre>

2. The ngrok utility will start and return a page similar to the below example:

<figure><img src="https://2414554083-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Feeqc6D5KqkgOsOW7j4k6%2Fuploads%2Fw7Qy1I2L9VuvEipAqnH7%2FScreenshot%20from%202024-04-18%2023-01-30.png?alt=media&#x26;token=a4010a10-501c-49b0-aff4-05ff72c5f592" alt=""><figcaption></figcaption></figure>

3. Your diagnostic address is in the **Forwarding** field. **Copy only the part of the address after the URL prefix&#x20;**<mark style="color:red;">**https\://**</mark>, in this case <mark style="color:blue;background-color:yellow;">e98b-95-245-79-203.ngrok-free.app</mark> .
4. In the machine hosting your Erigon node, go to the Erigon directory and run this command to attach the Diagnostic Tool to the Erigon node:

{% code overflow="wrap" %}

```bash
./build/bin/erigon support --diagnostics.addr YOUR_DIAGNOSTIC_ADDRESS --diagnostics.sessions YOUR_SESSION_PIN
```

{% endcode %}

5. Replace YOUR\_DIAGNOSTIC\_ADDRESS with the address obtained with ngrok
6. Replace YOUR\_SESSION\_PIN with your session **PIN** from [point 3](#id-3.-create-a-new-session-in-the-diagnostic-tool). For example:

`./build/bin/erigon support --diagnostics.addr e98b-95-245-79-203.ngrok-free.app --diagnostics.sessions 14606762`

By following these steps, you can establish a connection between the Diagnostic Tool on your local machine and the Erigon node running on the VPS, enabling you to monitor and diagnose the node's performance.
{% endtab %}
{% endtabs %}

*More information about the `erigon support` command can be find* [***here***](https://github.com/ledgerwatch/erigon/blob/main/turbo/app/README.md#support)*.*

## 5. Refresh the Diagnostic Tool

Once the diagnostics tool is successfully connected to the Erigon node, return to your web browser and reload the page.&#x20;

This step is necessary to query data from the connected node.

{% content-ref url="user-interface" %}
[user-interface](https://docs.erigon.tech/erigon/v2/diagnostic-tool/user-interface)
{% endcontent-ref %}
