Monitoring your Network
OverviewCopied!
You probably want to monitor the traffic and connections in your network. There are three primary ways to do this with Netmaker:
-
The built-in Metrics dashboard
-
A prometheus exporter and a Grafana dashboard template
-
View network data directly on the devices using built-in WireGuard features.
In this section, we will overview how to use these features.
Monitoring Network Stats with the Metrics DashboardCopied!
The netmaker server collects all types of valuable metrics from all the netclients and provides an overview of these aggregated metrics inside the Netmaker web UI. Also, we need to make sure that we are using the Netmaker Professional / Enterprise Edition for getting this feature of metrics. To access these metrics, we will have to log into the netmaker dashboard first. After that we should navigate to the specific network of interest from the networks tab. And then click on the metrics tab from above.
Now, we can see that different types of metrics are visible to us. The first page shows us the connectivity status of all the hosts inside the network to each other. It provides an overview of which hosts in the network each host can establish connectivity with.
In the above picture we can see that the host named “centos-userspace” can able to connect and communicate with the host named “ubuntu20-04” and vice versa. The same way in the below picture we can see that the host named “fedora” cannot connect or communicate with the host named “relayed” and vice versa.
Let’s move on to the new section of “Latency”.This metrics page shows the round trip time in milliseconds for a data packet between two different hosts. For example, we can see the round trip time / latency / ping between the host named “centos-userspace” and the host named “ubuntu20-04” is 149ms and vice versa.
Now, we navigate to the “Bytes Sent” tab and we can see the amount of data sent from the hosts on the left to the hosts on the top.
For example, in the above picture, we can see that a total of “390.56 MiB” of data is sent from the host named “Ubuntu20-04” to the host named “centos-userspace”. Also, from this data we can conclude that the host named “centos-userspace” received a total of “390.56 MiB” of data from the host named “Ubuntu20-04”.
Now, we navigate to the “Bytes Received” tab and we can see the amount of data received to the hosts on the left from the hosts on the top.
For example, in the above picture, we can see that a total of “313.73 MiB” data is received on the host named “Ubuntu20-04” from the host named “centos-userspace”. Also, from this data we can conclude that the host named “centos-userspace” sent a total of “313.73 MiB” data to the host named “Ubuntu20-04”.
Now, we navigate to the “Uptime” tab and we can see the uptime percentage for the connection between two specific hosts.
For example, in the above picture, we can see the total uptime percentage of connectivity on the host named “Ubuntu20-04” and the host named “centos-userspace” which is “100.00%” in this case.
On the last metrics page named “Clients” we can see the connection status, uptime percentage, latency, total data sent and received for any static external clients created under a “Remote Access Gateway”. The picture below shows the metrics for a static client named “road-warrior” which is not connected or lost connection to the remote access gateway.
These are all the metrics which are available to us in the Netmaker Professional / EE version using the netmaker web ui.
Exporting Metrics via PrometheusCopied!
The Netmaker exporter plugin can fetch statistics from the netmaker server in the format used by that system and convert those statistics into metrics that prometheus can utilize, and then expose them on a prometheus-friendly URL.By default the netmaker-exporter plugin runs on the domain https://netmaker-exporter.nm.your-domain-name.com. And prometheus can be set to collect metrics from this exporter plugin using this URL.
Prometheus is installed by default on the EE installation of netmaker. But for a manual installation of prometheus you can look into the official documentation in this link: https://prometheus.io/docs/prometheus/latest/installation
Now, to open the prometheus installation which was done by default with netmaker EE installation, we can navigate to https://prometheus.nm.your-domain-name.com
It will prompt for a login and the username for this login is “Netmaker-Prometheus” and the password is your netmaker EE license key. After login, you will see a dashboard like shown below.
Now if we navigate to “Status -> Configuration” we can see that the netmaker exporter is added as a scrape config in this configuration file. This is using the netmaker-exporter plugin url for scraping the metrics. This can be set or modified in the prometheus.yml file when installing prometheus to include custom exporters for scraping metrics data from them. But this has already been set in the default prometheus instance which comes with netmaker EE installation.
If we navigate to the “Status -> Targets” we can see that there is the netmaker-exporter endpoint up and running with some status / details of this endpoint.
Importing Metrics via GrafanaCopied!
The Grafana dashboard is a way of visualizing the metrics data collected and stored by the prometheus instance. To install grafana, you should follow the official installation documentation at https://grafana.com/docs/grafana/latest/setup-grafana/installation. By default an instance of the grafana dashboard is installed by the netmaker EE installation and runs on the domain https://grafana.nm.your-domain-name.com. Upon visiting the URL, you will be asked to login and the default username and password here is”admin” and “admin” respectively. After the initial login, it will ask you to set a new password. When finished, you will be greeted with the default home page of the grafana dashboard as shown below.
Now if we navigate to the hamburger menu on top left and click on the “Connections” tab, we will be able to see all the data sources which are available to us. We can use this menu to add a new data source such as prometheus.
Let’s search for prometheus and click on it.
Now if we click on the “Create a Prometheus data source” button, it will add a prometheus data source and open up a configuration page for the data source. In this configuration page we can add the prometheus instance URl that we previously acquired.
We can configure the name, prometheus endpoint / server url, authentication settings and scraping settings here on this page as shown below.
After pressing the “Save & Test” button at the end of this page, the prometheus configuration will be saved and tested. Now, we can begin setting up our grafana dashboard with the collected metrics from the prometheus server. But before that if we navigate to the “Data sources” tab on the left, we can see that the default netmaker prometheus instance is added to the default grafana installation through the netmaker EE installation process. And we will not need to add the prometheus endpoint manually.
Now again, if we click on the hamburger menu and navigate to “Dashboards” we can see that a default netmaker dashboard is already added for us through the netmaker EE installation process and if we click on the Netmaker dashboard, we will be able to see the metrics that we previously saw on the netmaker web ui.
While inside the netmaker metrics dashboard if we click on the small gear icon on top right, we can see the dashboard settings. And from there if we go to the “JSON Model” tab and copy the whole json, we can use it to import this netmaker metrics dashboard to any other custom grafana instance.
To import the dashboard, simply navigate to the dashboards menu and then click on the “New -> Import” button.
Now paste the previously copied JSON on this field and press the “Load” button to add the dashboard to grafana.
Using WireGuard to Check Network Statistics on DevicesCopied!
If we have the wireguard-tools package installed on our client systems, we will be able to view the wireguard interface statistics which are collected by the netclient. To get the wireguard-tools package on linux, we have to execute this command “sudo apt install wireguard-tools” on the linux system. Then if we use the “wg show” command, it will give us certain metrics and details about our wireguard connection as shown below.
We can see the bytes sent and received by this client to and from the specific peer. Also, we can see the latest handshake time. These metrics are some of what the netclient collects for showing up on the netmaker web ui or export to prometheus.