How to Install Unifi Unpoller

If you use a Ubiquiti Unifi Router, you can provide better data than what is in the Unifi Dashboard using Unpoller. Unpoller is a lightweight program to collect data from the Unifi controller and summarize that data using the open source Grafana analytics and visualization web based application. Unpoller is a docker application consisting of three Docker containers which include an Influx database, the Grafana analytics app, and the Unpoller application.

To install Docker:

sudo apt install curl
curl -sSL https://get.docker.com | sh
sudo usermod -aG docker $(whoami)
newgrp docker
groups

Install Docker-Compose

sudo apt install docker-compose

Create application folders:

mkdir docker
cd docker
mkdir grafana
mkdir influxdb
mkdir unpoller

Create docker-compose.yml file:

nano docker-compose.yml

Insert the following code:

version: "3"
services:
  influxdb:
    container_name: up_influxdb
    restart: unless-stopped
    image: influxdb:1.8
    ports:
      - '8086:8086'
    volumes:
      - /home/scott/docker/influxdb:/var/lib/influxdb
    environment:
      - INFLUXDB_DB=unifi
      - INFLUXDB_ADMIN_USER=unifi
      - INFLUXDB_ADMIN_PASSWORD=unifi
 
  grafana:
    container_name: up_grafana
    image: grafana/grafana
    restart: unless-stopped
    user: 1000:1000
    ports:
      - '3000:3000'
    volumes:
      - /home/scott/docker/grafana:/var/lib/grafana
    depends_on:
      - influxdb
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_INSTALL_PLUGINS=grafana-clock-panel,natel-discrete-panel,grafana-piechart-panel
 
  unifi-poller:
    container_name: up-poller
    restart: unless-stopped
    image: golift/unifi-poller:latest
    depends_on:
      - influxdb
      - grafana
    volumes:
      - /home/scott/docker/unpoller:/config

Modify the paths above on the left side of the colon in the volume sections and modify the influx database name, username and password to meet your needs.

cd unpoller
nano unifi-poller.conf

Insert this code in the unifi-poller.conf file:

[unifi.defaults]
  url  = "https://172.16.0.1"
  user = "unpolleruser"
  pass = "Mypassword1"
  save_dpi = true
[influxdb]
  url  = "http://172.16.5.5:8086"

The first URL above should be the location of your Unifi controller address. The second URL should be the IP address of your docker host.

Be sure to create a user account on your Unifi device to match the configuration file above. You can of course name the account anything you want and set any password as long as it matches.
Unpoller Username

Test your application:

cd ..
docker-compose up

Any errors will be in the two configuration files.

Now go to: http://your-docker-host:3000
Log in with admin/admin and change your password.

Choose Configuratiion on the left hand side, then “Data Sources”. “Add data source”, choose InfluxDB then fill in the details of the URL:

http://your-docker-address:8086

Include the Influx details: (database – unifi, User – unifi, Password – unifi), then Save & Test.

Finally, go to the Plus “+” sign and choose import and import the dashboard ID’s 10414, 10415, 10416, 10417, 10418 and 10419.

You should now be up and running!

Last, do a CTRL-C in the terminal to get out of docker-compose and then:

docker-compose up -d

Great video on this but getting this error. Is this not supported on self hosted controller on Linus?

Thanks

2024/01/30 15:23:36 [ERROR] metric fetch for InfluxDB failed: re-authenticating to https://127.0.0.1:8443: unifi controller: making request: Get “https://127.0.0.1:8443/”: dial tcp 127.0.0.1:8443: connect: connection refused: error initializing inputs

The error shows that you left your Unifi Controller address as the loop back address. It needs to be the host address of where you are hosting your unifi controller and if that controller is running in Docker, you need to have the API port number open to your LAN. By default, the Unifi controller API uses port 8443.

Hello there, thanks for the reply. The correct IP for the controller is in the .conf file. However deeper digging it seems that the unpoller container is loading a differnet up.conf file. Since there is no /bin/bash in that container I can’t docker exec into the file system to see the contents of that file it’s loading. Not sure where it got that from. Will blow it up and start from scratch to see if I might have misconfigure something along the way. Cheers!

No matter what I do, for some reason unpoller is still trying to get to 127.0.0.1. Even switched to a remote unifi controller at a completely different IP, re-created containers and the logs still show it’s hitting 127.0.0.1. No idea where this setting is buried.

It’s going on close to two years since I made this video. If you want, come join in my chat at https://chat.scottibyte.com/ and we can try to work this out.

As info: unifi.local is a UCG-Ultra cloud gateway, docker is running on a Raspberry Pi 4b.

I struggled with 3 different variants of unifi-poller before getting this one to work. I had to add an environment section in the portainer stack to get everything to work. Also, had to create a grafana user (472:0) on my PI, then chown the directory for grafana to work.

On the influxdb, it seemed to work without the ORG and BUCKET settings (others wanted them to be “unifi”). I haven’t experimented to see if that works for the other stacks as well. This ain’t broke, not sure I need to fix the others.

Here’s my complete stack:

version: "3"
services:
  influxdb:
    container_name: up_influxdb
    restart: unless-stopped
    image: influxdb:1.8
    ports:
      - '8086:8086'
    volumes:
      - /srv/scottibyte/influxdb:/var/lib/influxdb
    environment:
      - INFLUXDB_DB=unifi
      - INFLUXDB_ADMIN_USER=unifi
      - INFLUXDB_ADMIN_PASSWORD=unifi
 
  grafana:
    container_name: up_grafana
    image: grafana/grafana
    restart: unless-stopped
    user: 472:0
    ports:
      - '3000:3000'
    volumes:
      - /srv/scottibyte/grafana:/var/lib/grafana
    depends_on:
      - influxdb
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=grafanaadmin
      - GF_INSTALL_PLUGINS=grafana-clock-panel,natel-discrete-panel,grafana-piechart-panel
 
  unifi-poller:
    container_name: up-poller
    restart: unless-stopped
    image: golift/unifi-poller:latest
    depends_on:
      - influxdb
      - grafana
    environment:
      - UP_UNIFI_DEFAULT_USER=unifipoller
      - UP_UNIFI_DEFAULT_PASS=UnifiPoller+2
      - UP_UNIFI_DEFAULT_URL=https://unifi.local/
      - UP_POLLER_DEBUG=false
      - UP_UNIFI_DEFAULT_SAVE_DPI=true
      - UP_INFLUXDB_URL=http://influxdb:8086
      - UP_INFLUXDB_DB=unifi
      - UP_INFLUXDB_USER=unifipoller
      - UP_INFLUXDB_PASS=unifipoller

    volumes:
      - /srv/scottibyte/unpoller:/etc/unifi-poller