klever node monitoring guide

vpS1TT3R
5 min readFeb 27, 2022

please be aware that this guide assumes you’re using ubuntu server 20.04 lts or similar.

when you have a running klever node or validator, you may be interested on how to make sure it stays up and running. in this case an uncomplicated and useful monitoring could be your desire.

as it is part of the klever blockchain validators program to set up and write about this topic, lets get it running.

a) what monitoring should we choose?

since the klever node runs in a docker container, we should choose a solution that is suitable for this. we also want to make it easy for ourselves and choose a simply structured web interface for later fine-tuning of the monitoring. the solution to these requirements is the combination of grafana and prometheus.

b) specific requirements

what is required to set up the monitoring specifically for klever node? the developers of the klever node have thought of us and provide an http api that grafana and prometheus can use. when we have setup our node as described in the docs the api is reachable http://yournodeip:8080/node/metrics

c) let’s set it up

first we want to install grafana and prometheus sudo apt install grafana and sudo apt install prometheus both should be automatically started after installation. check if grafana is running sudo systemctl status grafana-server if not running we can start with sudo systemctl start grafana-server we can make sure it starts on reboots with sudo systemctl enable grafana-server

d) grafana security

after installing grafana, the web interface can be used with a default password, which we want to change as soon as we can (defaults are username: admin | password: admin). you can open the webinterface as follows:

http://yourserverip:3000

login with admin user and admin password and change the password to a unique and not to simple one. don’t use your server user passwords as our http connection is not ssl encrypted and could be compromised.

in addition we disable registration for new users on the webinterface by editing the grafana settings with ssh in /etc/grafana/grafana.ini we change the line ;allow_sign_up = true to allow_sign_up = false and remove the semicolon. following reload of grafana settings with sudo systemctl reload grafana

if we want to share our dashboard later without user login, we can allow anonymous access. should only be used consciously and later deactivated. in grafana.ini we have to find the section [auth.anonymous] and change from ;enabled = false to enabled = true and remove the semicolon. following reload of grafana settings with sudo systemctl reload grafana

e) configure api access

the api communication is done by prometheus and we can configure it by appending the following code block at the end of the prometheus configuration file, which can be found here: /etc/prometheus/prometheus.yml

- job_name: validatormetrics_path: ‘/node/metrics’scrape_interval: 5sstatic_configs:- targets: [‘localhost:8080’]

to make sure the configuration is active we reload it sudo systemctl reload prometheus

f) grafana data source

to make prometheus usable for grafana we have do add it as a data source. navigate on the webinterface to data sources

and choose prometheus from selection

we can change the name or leave it as it is and click on save & test at the bottom of the site

g) setting up a dashboard

thanks to a hardworking member of the klever community you can download a json file with an already nicely set up dashboard to import from here

the import can be done from the webinterface

here you can paste the json plaintext in the “import via panel json” field

following parts of the json should be modified:

at the top of the json data: datasource”: “ — Grafana — “,

change to the given name of your prometheus data source

at the bottom of the json data: “title”: “Your Title”, “uid”: “Your UID”,

choose a title in the part “Your title” and an UID in the part “Your UID” (can be any, it’s used for created sub-url, do not use spaces)

next you can press load and then import

h) use your dashboard

on the webinterface click dashboards, browse

there you should see the imported dashboard like this

choose the imported dashboard and you should see something similar to this

when you don’t see data in the windows, go on each headline, click edit and set the correct data source manually (again), press apply, press save, repeat for all windows.

now we have successful setup a basic monitoring for our klever node

i) share dashboard

because we didn’t deactivated anonymous access to the view mode of our dashboards, we can share a link, click the share symbol on the right side of your dashboard headline

there you should see the url of your dashboard which can be shared (only view mode for not logged in users)

j) useful additions

makes sense, but is not covered by these instructions: e-mail notifications, ssl encryption for webinterface access, fine-tuning of dashboard

--

--

vpS1TT3R

earn passive income with klever staking and join a community of klever people around the world https://klever.page.link/uwEp8oJXfPv6YLcL7