A swamp repository that collects and monitors traffic data from a Ubiquiti UniFi Dream Machine (UDM).
The @stack72/unifi-traffic extension model connects to your UDM and collects:
- Site Traffic - Hourly WAN and WLAN traffic totals for the past 24 hours
- Client Traffic - Per-device usage, signal strength, and connection details
- DPI Stats - Deep packet inspection category breakdown (when available)
- swamp installed
- A UniFi Dream Machine (UDM, UDM Pro, UDM SE, etc.)
- Either local network access to the UDM or a Ubiquiti cloud API key
If starting fresh:
swamp repo initswamp vault create secretsThe model supports two modes: local (direct connection to UDM) and cloud (via Ubiquiti's cloud API).
Connects directly to the UDM over your local network. Requires a local admin user on the UDM.
Create the local admin user on your UDM:
- Open the UniFi app or web UI
- Go to Settings > Admins & Users
- Create a new admin user (e.g.
swamp) with SuperAdmin role - Set access to "Local Access Only"
Store the password:
swamp vault put secrets UDM_PASSWORD
# Enter the password when promptedCreate the model instance:
swamp model create @stack72/unifi-traffic udm-trafficConfigure the global arguments:
swamp model edit udm-trafficSet the globalArguments section in the definition:
globalArguments:
mode: "local"
host: "192.168.1.1"
username: "swamp"
password: ${{ vault.get(secrets, UDM_PASSWORD) }}
site: "default"Replace
192.168.1.1with your UDM's IP address if different.
Connects via the Ubiquiti cloud API. Provides better device name resolution (fingerprint-based names) but requires an API key.
Get your API key:
- Go to https://unifi.ui.com
- Click your profile icon > Account Settings
- Under API Keys, generate a new key
Store the API key:
swamp vault put secrets UNIFI_API_KEY
# Enter the API key when promptedCreate the model instance:
swamp model create @stack72/unifi-traffic udm-trafficConfigure the global arguments:
swamp model edit udm-trafficSet the globalArguments section in the definition:
globalArguments:
mode: "cloud"
apiKey: ${{ vault.get(secrets, UNIFI_API_KEY) }}
site: "default"Use cloud mode with local credentials as fallback. Cloud mode provides better device name resolution by using the v2 API for fingerprint-based display names.
swamp vault put secrets UDM_PASSWORD
swamp vault put secrets UNIFI_API_KEYswamp model create @stack72/unifi-traffic udm-trafficThen configure the global arguments:
swamp model edit udm-trafficSet the globalArguments section in the definition:
globalArguments:
mode: "cloud"
host: "192.168.1.1"
username: "swamp"
password: ${{ vault.get(secrets, UDM_PASSWORD) }}
site: "default"
apiKey: ${{ vault.get(secrets, UNIFI_API_KEY) }}swamp model method run udm-traffic collect# View the latest collection
swamp model get udm-traffic --json
# View collected data
swamp data list udm-trafficHourly breakdown of the past 24 hours including:
- WAN upload/download bytes
- WLAN bytes
- Number of connected clients
Per-device snapshot including:
- Device name (resolved from multiple sources)
- IP and MAC address
- Upload/download bytes and current rate
- WiFi signal strength (dBm)
- SSID and network
- Top clients by usage percentage
Traffic categories (e.g. Streaming, Social Media, Gaming) when Deep Packet Inspection is enabled on the UDM under Settings > Traffic Management > Traffic Identification.
- Local mode uses
curlunder the hood to handle the UDM's self-signed TLS certificate - Cloud mode discovers your UDM's host ID and site ID automatically from the API
- Device names are resolved from multiple sources: user-assigned names, hostnames, and (in cloud mode) Ubiquiti's device fingerprint database
- The model writes a
logfile with collection details for debugging