Code Monkey home page Code Monkey logo

unifi_exporter's Introduction

unifi_exporter GoDoc Build Status Coverage Status

Command unifi_exporter provides a Prometheus exporter for a Ubiquiti UniFi Controller API and UniFi devices.

Package unifiexporter provides the Exporter type used in the unifi_exporter Prometheus exporter.

MIT Licensed.

Seeking additional maintainers

Due to the wide variety of UniFi devices available, and because the UniFi APIs are unstable, Matt Layher is unable to dedicate the time and energy needed to maintain this exporter on his own.

At this time, there are no official releases or Docker images available. Building the exporter from master is the expected method to deploy it.

If you are interested in maintaining this exporter and have demonstrated a history of submitting solid improvements to the project, I am happy to grant push access to remove myself as a roadblock for progress.

Usage

$ ./unifi_exporter -h
Usage of ./unifi_exporter:
  -config.file string
       Relative path to config file yaml

To run the exporter, edit the included config.yml.example, rename it to config.yml, then run the exporter like so:

$ ./unifi_exporter -config.file config.yml
2017/11/15 17:06:32 [INFO] successfully authenticated to UniFi controller
2017/11/15 17:06:32 Starting UniFi exporter on ":9130" for site(s): Default

The minimum you'll need to modify is the unifi address, username and password. The port defaults to 8443 as specified in the config file, and the defaults in 'listen' are sufficient for most users.

Sample

Here is a screenshot of a sample dashboard created using grafana with metrics from exported from unifi_exporter.

sample

Thanks

Special thanks to Vaibhav Bhembre for his work on ceph_exporter. ceph_exporter was used frequently as a reference Prometheus exporter while implementing unifi_exporter.

unifi_exporter's People

Contributors

akramer avatar bachp avatar cmsj avatar mdlayher avatar metalmatze avatar mttradebyte avatar rubenv avatar someone1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unifi_exporter's Issues

Automated build on Docker Hub

Hey

I was just wondering if you'd be willing to set up an automated build on hub.docker.com for this repo :)

There are a few people who have forked the repo and set up their own builds, but that relies on them pulling in circles from here.

Cheers,
Chris

[feature request] Number of Clients per SSID

Hello,

I run a setup where I have different user groups seperated by SSIDs on the same site. I'd really like to have a feature to show the number of clients on each SSID, e. g. :

unifi_stations{ssid="A"} 110
unifi_stations{ssid="B"} 23

For my usecase a further differentation in sites would no be necessary. But the more sustainable implementation would probably be:

unifi_stations{site="X",ssid="A"} 110
unifi_stations{site="X",ssid="B"} 23
unifi_stations{site="Y",ssid="A"} 12
unifi_stations{site="Y",ssid="C"} 16

Thanks for considering!

Link in DockerHub

I think this is great and thank you for it. I read the other issue regarding this topic but it sounds like there's some confusion on how we can get this setup...

@mdlayher Since you own the repo you need to link it in the Docker hub: https://hub.docker.com/r/mdlayher/

You can just follow the steps here to get this repository on the hub and set up with automated builds! It should hopefully only take a few minutes and once it's setup you won't really need to worry about it.

I see a lot of forks of this repository on Docker Hub but they are months behind in terms of PR's and such. It'd be a lot more straightforward to just link this to the Docker Hub directly.

My apologies for opening a separate issue for this, but it seems the other one is closed and is not getting any attention.

Trouble building

This is likely purely because I'm new to building and go, but I'm getting tripped up on building from this project. I've cloned the project, but when I use make I'm getting this:

sysadmin@prometheus-srv:~/docker/unifi_exporter$ make
go build ./cmd/unifi_exporter
cmd/unifi_exporter/main.go:13:2: cannot find package "github.com/mdlayher/unifi" in any of:
	/usr/local/go/src/github.com/mdlayher/unifi (from $GOROOT)
	/home/sysadmin/work/src/github.com/mdlayher/unifi (from $GOPATH)
cmd/unifi_exporter/main.go:14:2: cannot find package "github.com/mdlayher/unifi_exporter" in any of:
	/usr/local/go/src/github.com/mdlayher/unifi_exporter (from $GOROOT)
	/home/sysadmin/work/src/github.com/mdlayher/unifi_exporter (from $GOPATH)
cmd/unifi_exporter/main.go:15:2: cannot find package "github.com/prometheus/client_golang/prometheus" in any of:
	/usr/local/go/src/github.com/prometheus/client_golang/prometheus (from $GOROOT)
	/home/sysadmin/work/src/github.com/prometheus/client_golang/prometheus (from $GOPATH)
Makefile:4: recipe for target 'build' failed
make: *** [build] Error 1

would you mind helping out a newer user on what I'm missing here?

password should not be configured on command line

When the password is specified on the command like it's very easy for unprivileged users to see the password. A config file should be used for at least the password, and it'd be nice to be able to use a config file for the other options as well.

Collecting device metric fails

unifi_exporter infrequently stops working and just responds with:

An error has occurred:

error collecting metric Desc{fqName: "unifi_devices", help: "Total number of devices", constLabels: {}, variableLabels: [site]}: failed to parse inform IP:

on the telemetry port.

AFACT the issue seems to occur when there are devices which are pending approval. The JSON object for this device returned by the unifi API does not have a inform_ip property.

So, the device parsing seems to be too strict.

[bug] exporter doesn't scrape all sites

I can export different sites on the same controller with the "-unifi.site" option.

Without the -unifi.site option, only one site (the first I created on the controller) is exported, but all sites should be scraped.

As a workaround I got several unifi_exporter processes running, one for each site.

thanks for having a look into it!

Don't crash if Unifi controller is down

2017/06/30 08:51:28 [INFO] successfully authenticated to UniFi controller
2017/06/30 08:51:28 Starting UniFi exporter on ":9130" for site(s): Thuis
2017/07/01 02:58:17 [ERROR] failed collecting station metric Desc{fqName: "unifi_stations", help: "Total number of stations (clients)", constLabels: {}, variableLabels: [site]}: Get https://192.168.1.30:8443/api/s/default/stat/sta: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/07/01 02:58:22 [ERROR] could not initialize UniFi client: failed to authenticate to UniFi Controller: Post https://192.168.1.30:8443/api/login: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/07/01 13:48:17 [ERROR] failed collecting device metric Desc{fqName: "unifi_devices", help: "Total number of devices", constLabels: {}, variableLabels: [site]}: Get https://192.168.1.30:8443/api/s/default/stat/device: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
2017/07/01 13:48:21 [INFO] successfully authenticated to UniFi controller
2017/07/02 08:47:20 failed to create client: failed to authenticate to UniFi Controller: Post https://192.168.1.30:8443/api/login: dial tcp 192.168.1.30:8443: getsockopt: connection refused

This happens when the machine running things is rebooted, takes a while before Unifi starts, the exporter is up much faster.

Probably needs a retry loop somewhere.

interference metrics

Hi! First, thanks for the exporter!

I'd love to be able to graph wifi interference. (Perhaps with labels for the access point and channel.) I haven't checked if the unifi api supports it.. but I thought I'd post the idea here and see if anyone else has time to dig in more..

Cheers,

Geoff

error 400 upon connect

Exporter dies after unexpectedly receiving a status code 400 from a Unifi Cloud Key.

Unifi 5.4.15
Cloud Key firmware 0.6.4

# ./unifi_exporter -unifi.addr https://unifi-key:8443/ -unifi.username unifiexporter -unifi.password password -unifi.insecure 2017/05/12 14:30:09 failed to create client: failed to authenticate to UniFi Controller: unexpected HTTP status code: 400

Error with Unifi 5.5.8

I'm getting the following error after upgrading the controller to 5.5.8

[ERROR] failed collecting device metric Desc{fqName: "unifi_devices", help: "Total number of devices", constLabels: {}, variableLabels: [site]}: json: cannot unmarshal number 3.733721026E9 into Go value of type int64

json error

failed to authenticate to UniFi Controller: expected "application/json;charset=UTF-8" content type, but received "application/json"

thanks

disconnected APs metric

Could someone provide some guidance on how to modify unifi_exporter for this? what files/functions should I look at?

Invalid MAC Address on IP:3190 load.

An error has occurred:

error collecting metric Desc{fqName: "unifi_stations", help: "Total number of stations (clients)", constLabels: {}, variableLabels: [site]}: invalid MAC address

Controller v5.3.7. What version on your running?

Unable to scrape metrics

When trying to accesss /metrics, getting this error:

An error has occurred during metrics collection:

error collecting metric Desc{fqName: "unifi_devices", help: "Total number of devices", constLabels: {}, variableLabels: [site]}: json: cannot unmarshal number 8.4287193168E10 into Go value of type int64

Controller 5.6.19

retries, tx errors, etc.

I'd like to be able to do like the chart below. I don't see these metrics. Is there any chance they could be added?
image

Better metrics for specific Unifi devices

This should probably go on package unifi, but since more folks follow the issues here:

Now that I have a unifi switch, I'd like to rework some metrics and remove some of the more hacky workarounds we have in place now. This issue will track that work.

-unifi.insecure does not appear to work

I use the default self-signed cert on my unifi server (version 5.1.1) and I get this error even though I have specified the -unifi.insecure flag. Using version 0.2.0 of the exporter.

/opt/unifi_exporter/0.2.0/unifi_exporter -telemetry.addr 127.0.0.1:9130 -unifi.addr https://192.168.4.2:8443/ -unifi.insecure -unifi.username jeff -unifi.password xxxxx
2016/09/07 23:29:55 failed to create client: failed to authenticate to UniFi Controller: Post https://192.168.4.2:8443/api/login: remote error: tls: handshake failure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.