Setting up a Grafana based monitor for your Hypernode node

Part 1: Setting up Grafana

Step 1: Set up the new server

First up you need to set up a new server to run your Hypernode node dashboard. You can set this up to run on your Hypernode server but it is NOT recommended.

Create new AWS EC2 instance

Start by creating for example a new AWS EC2 instance (https://aws.amazon.com/ec2/):

  • Amazon Machine Image (AMI): Ubuntu Server 18.04 LTS (HVM), SSD Volume Type
  • Instance Type: t3.micro

Configure Security Groups

Add the following Custom TCP rules to allow inbound traffic to Grafana and Prometheus:

  • Grafana
  • Type: Custom TCP Rule
  • Port Range: 3000
  • Description: Grafana
  • Prometheus
  • Type: Custom TCP Rule
  • Port Range: 9090
  • Description: Prometheus

Step 2: Installing Prometheus on the new server

Next up you need to install Prometheus on your new server. Prometheus will collect all the real time metrics from your Hypernode machine and store them in a time series database.

Step 3: Install node_exporter on the Hypernode node

As well as the Hypernode specific metrics we also want to capture the server metrics so we can see how the server is performing (eg. RAM usage, CPU, etc.). To enable this you need to install the node_exporter.

Create Prometheus system user / group

We’ll create a dedicated Prometheus system user and group. The -r or –system option is used for this purpose.

sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

Install node_exporter

Download node_exporter archive.

curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest \
| grep browser_download_url \
| grep linux-amd64 \
| cut -d '"' -f 4 \
| wget -qi -
tar -xvf node_exporter*.tar.gz
cd node_exporter*/
sudo cp node_exporter /usr/local/bin
node_exporter --version
sudo tee /etc/systemd/system/node_exporter.service <<EOF
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target[Service]
User=prometheus
ExecStart=/usr/local/bin/node_exporter[Install]
WantedBy=default.target
EOF
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
systemctl status node_exporter.service

Step 4: Configure Prometheus to get Hypernode metrics

Ok, now you have Prometheus and the node exporter installed you need to set it up to get the metrics from the Hypernode node.

Configure Prometheus to retrieve metrics from the Hypernode server

Now you need to configure Prometheus to retrieve the Hypernode metrics.

sudo nano /etc/prometheus/prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'general' # metrics_path defaults to '/metrics'
# scheme defaults to 'http'. static_configs:
- targets: ['IP_ADDRESS:9100']
labels:
instance: 'NODE_NAME'
- job_name: 'blockpi_hypernode'
metrics_path: /metrics static_configs:
- targets: ['IP_ADDRESS:8899']
labels:
instance: 'NODE_NAME'
sudo systemctl restart prometheus

Step 5: Installing Grafana

Ok now we have all the metrics we want to visualise all them on a fancy dashboard that looks gorgeus :) Grafana is just what we need for this.

Step 6: Connect Grafana to Prometheus Data Source

Now to connect Grafana to our data.

Step 7: Importing my sample Hypernode Node Dashboard

To import the sample Hypernode Node Dashboard click on the ‘Create’ menu on the left and select ‘Import’.

Part 2: Setting up Grafana Alerts in Discord

If you would like to receive alerts in Discord when your Hypernode Node is down or not replying to requests then continue on!

Step 2: Set up the webhook integration

Select the ‘edit channel’ button next to the channel name and then select the ‘Integrations’ menu option on the left and select ‘Create Webhook’.

Step 3: Set up the Discord Notification Channel in Grafana

Open up your Grafana dashboard (http://IP_ADDRESS:3000/) and select ‘Alerts’ and then ‘Notification Channels’.

Step 4: Setting up the Alert

Now open the dashboard and go to the panel where you want to set up an alert, select the header and then the ‘Edit’ option. Then, inside of the Alert section, as shown in the image, set up the alert according to your needs:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store