promunifi

package
v1.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 8 Imported by: 0

README

prometheus

This package provides the interface to turn UniFi measurements into prometheus exported metrics. Requires the poller package for actual UniFi data collection.

Documentation

Overview

Package promunifi provides the bridge between unifi metrics and prometheus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUnifiCollector

func NewUnifiCollector(opts UnifiCollectorCnfg) prometheus.Collector

NewUnifiCollector returns a prometheus collector that will export any available UniFi metrics. You must provide a collection function in the opts.

Types

type Report

type Report struct {
	Total   int              // Total count of metrics recorded.
	Errors  int              // Total count of errors recording metrics.
	Zeros   int              // Total count of metrics equal to zero.
	Descs   int              // Total count of unique metrics descriptions.
	Metrics *metrics.Metrics // Metrics collected and recorded.
	Elapsed time.Duration    // Duration elapsed collecting and exporting.
	Fetch   time.Duration    // Duration elapsed making controller requests.
	Start   time.Time        // Time collection began.
	// contains filtered or unexported fields
}

Report is passed into LoggingFn to log the export metrics to stdout (outside this package).

type UnifiCollectorCnfg

type UnifiCollectorCnfg struct {
	// If non-empty, each of the collected metrics is prefixed by the
	// provided string and an underscore ("_").
	Namespace string
	// If true, any error encountered during collection is reported as an
	// invalid metric (see NewInvalidMetric). Otherwise, errors are ignored
	// and the collected metrics will be incomplete. Possibly, no metrics
	// will be collected at all.
	ReportErrors bool
	// This function is passed to the Collect() method. The Collect method runs
	// this function to retrieve the latest UniFi measurements and export them.
	CollectFn func() (*metrics.Metrics, error)
	// Provide a logger function if you want to run a routine *after* prometheus checks in.
	LoggingFn func(*Report)
}

UnifiCollectorCnfg defines the data needed to collect and report UniFi Metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL