Grafana on Azure (part 2)

In part 1 of this series post I gave brief explanation on how to install and configure Grafana, how to configure Azure monitor plugin and start collecting data from Azure virtual machines.

In this post I will go through Grafana setup to monitor and visualize data from Unifi controller that is also running in Azure virtual machine on Ubuntu distribution.

Unifi-pooler

Unifi-pooler is small piece of software that is running on virtual machine where Unifi controller is located. It pulls data from the controller and saves it into the InfluxDB database. Grafana then connects to that database, collects data and visualizes it.

Create unifi-pooler account in Unifi

  1. Go to Settings -> Admins
  2. Add a read-only user (unifipoller) with a nice long password.
  3. The new user needs access to each site. For each UniFi Site you want to poll, add admin via the ‘Invite existing admin’ option or in newer versions just select option to inherit to all sites.
  4. Take note of the username and password, you need to put it into the unifi-poller config file.

Install InfluxDB and create database

First we need to install InfluxDB on Unifi controller

echo "deb https://repos.influxdata.com/ubuntu bionic stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
sudo apt -y update
sudo apt install -y influxdb
sudo systemctl start influxdb

Than we need to create new database

influx -host localhost -port 8086
CREATE DATABASE unifi
USE unifi
CREATE USER unifipoller WITH PASSWORD 'unifipoller' WITH ALL PRIVILEGES
GRANT ALL ON unifi TO unifipoller

Notice

Make note of the hostname, port, database name, and user/pass for the unifi-poller config file.

Install unifi-pooler

curl -s https://golift.io/gpgkey | sudo apt-key add -
echo deb https://dl.bintray.com/golift/ubuntu bionic main | sudo tee /etc/apt/sources.list.d/golift.list
sudo apt update
sudo apt install unifi-poller

Edit config file

Use your favorite editor

sudo nano /etc/unifi-poller/up.conf

or if you a hard core command line guru

sudo vi /etc/unifi-poller/up.conf

You will want to change these settings

[unifi.defaults]
  url  = "https://your.unifi.controller.ip:8443"
  user = "unifipoller"
  pass = "unifipoller"
[influxdb]
  url  = "http://your.influxdb.ip:8086"

Don’t forget to enter correct username and password and open required ports if you have firewall.

Restart the service
sudo systemctl restart unifi-poller
Check the log for errors
tail -f -n100  /var/log/syslog /var/log/messages | grep unifi-poller

Add the data source to Grafana

As in part 1 when we configured Azure monitor as data source, now we need to ad InfluxDB as data source.

  1. Open the side menu by clicking the Grafana icon in the top header.
  2. In the side menu under the Dashboards link you should find a link named Data Sources.
  3. Click the + Add data source button in the top header.
  4. Select InfluxDB from the Type dropdown.
  5. Select InfluxQL or Flux from the Query Language list.

Add Unifi dashboards to Grafana

At this point, data is being ingested in InfluxDB and all that is left is to add dashboards to the Grafana interface.

Grafana official repository contains several interesting Unifi dashboards for free. Installation is easy and straightforward as explained in part 1.

Since some of these dashboards contain additional plugins, I recommend you to install them beforehand on Grafana VM.

Clock plugin

grafana-cli plugins install grafana-clock-panel

Pie-chart plugin

grafana-cli plugins install grafana-piechart-panel

Restart Grafana server

service grafana-server restart

I had some issues with UniFi-Poller: Client Insights – InfluxDB dashboard because it uses Discrete plugin which installs fine but for some reason does not work in dashboard.

You May Also Like

About the Author: Marin

Started as trainer and administrator in Algebra, 5 years later became head of operating systems department at Algebra private college. At that time, he became IT Pro group lead and 5-year Microsoft MVP. Joined Microsoft in 2014. and after covering roles of Infrastructure and Azure TSP for 4 years, moved to Span to take the role of Senior Solutions Architect for cloud solutions. Currently holds Microsoft Azure MVP award. Personal time is occupied by enjoying short trips with his family and close friends, tinkering with home automation and networking and spending money on too many gadgets.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.