Documentation ¶
Overview ¶
Package datadogunifi provides the methods to turn UniFi measurements into Datadog data points with appropriate tags and fields.
Index ¶
- func Combine(in ...map[string]any) map[string]any
- func CombineFloat64(in ...map[string]float64) map[string]float64
- type Config
- type Counts
- type Datadog
- type DatadogUnifi
- func (u *DatadogUnifi) DebugOutput() (bool, error)
- func (u *DatadogUnifi) Enabled() bool
- func (u *DatadogUnifi) LogDatadogReport(r *Report)
- func (u *DatadogUnifi) LogDebugf(msg string, v ...any)
- func (u *DatadogUnifi) LogErrorf(msg string, v ...any)
- func (u *DatadogUnifi) Logf(msg string, v ...any)
- func (u *DatadogUnifi) PollController()
- func (u *DatadogUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Report, error)
- func (u *DatadogUnifi) Run(c poller.Collect) error
- type Report
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // Interval controls the collection and reporting interval Interval cnfg.Duration `json:"interval,omitempty" toml:"interval,omitempty" xml:"interval,omitempty" yaml:"interval,omitempty"` // Save data for dead ports? ie. ports that are down or disabled. DeadPorts bool `json:"dead_ports,omitempty" toml:"dead_ports,omitempty" xml:"dead_ports,omitempty" yaml:"dead_ports,omitempty"` // Enable when true, enables this output plugin Enable *bool `json:"enable" toml:"enable" xml:"enable,attr" yaml:"enable"` // Address determines how to talk to the Datadog agent Address string `json:"address" toml:"address" xml:"address,attr" yaml:"address"` // Namespace to prepend to all metrics, events and service checks name. Namespace *string `json:"namespace" toml:"namespace" xml:"namespace,attr" yaml:"namespace"` // Tags are global tags to be applied to every metrics, events and service checks. Tags []string `json:"tags" toml:"tags" xml:"tags,attr" yaml:"tags"` // MaxBytesPerPayload is the maximum number of bytes a single payload will contain. // The magic value 0 will set the option to the optimal size for the transport // protocol used when creating the client: 1432 for UDP and 8192 for UDS. MaxBytesPerPayload *int `json:"max_bytes_per_payload" toml:"max_bytes_per_payload" xml:"max_bytes_per_payload,attr" yaml:"max_bytes_per_payload"` // MaxMessagesPerPayload is the maximum number of metrics, events and/or service checks a single payload will contain. // This option can be set to `1` to create an unbuffered client. MaxMessagesPerPayload *int `` /* 131-byte string literal not displayed */ // BufferPoolSize is the size of the pool of buffers in number of buffers. // The magic value 0 will set the option to the optimal size for the transport // protocol used when creating the client: 2048 for UDP and 512 for UDS. BufferPoolSize *int `json:"buffer_pool_size" toml:"buffer_pool_size" xml:"buffer_pool_size,attr" yaml:"buffer_pool_size"` // BufferFlushInterval is the interval after which the current buffer will get flushed. BufferFlushInterval *cnfg.Duration `json:"buffer_flush_interval" toml:"buffer_flush_interval" xml:"buffer_flush_interval,attr" yaml:"buffer_flush_interval"` // BufferShardCount is the number of buffer "shards" that will be used. // Those shards allows the use of multiple buffers at the same time to reduce // lock contention. BufferShardCount *int `json:"buffer_shard_count" toml:"buffer_shard_count" xml:"buffer_shard_count,attr" yaml:"buffer_shard_count"` // SenderQueueSize is the size of the sender queue in number of buffers. // The magic value 0 will set the option to the optimal size for the transport // protocol used when creating the client: 2048 for UDP and 512 for UDS. SenderQueueSize *int `json:"sender_queue_size" toml:"sender_queue_size" xml:"sender_queue_size,attr" yaml:"sender_queue_size"` // WriteTimeoutUDS is the timeout after which a UDS packet is dropped. WriteTimeoutUDS *cnfg.Duration `json:"write_timeout_uds" toml:"write_timeout_uds" xml:"write_timeout_uds,attr" yaml:"write_timeout_uds"` // ReceiveMode determines the behavior of the client when receiving to many // metrics. The client will either drop the metrics if its buffers are // full (ChannelMode mode) or block the caller until the metric can be // handled (MutexMode mode). By default the client will MutexMode. This // option should be set to ChannelMode only when use under very high // load. // // MutexMode uses a mutex internally which is much faster than // channel but causes some lock contention when used with a high number // of threads. Mutex are sharded based on the metrics name which // limit mutex contention when goroutines send different metrics. // // ChannelMode: uses channel (of ChannelModeBufferSize size) to send // metrics and drop metrics if the channel is full. Sending metrics in // this mode is slower that MutexMode (because of the channel), but // will not block the application. This mode is made for application // using many goroutines, sending the same metrics at a very high // volume. The goal is to not slow down the application at the cost of // dropping metrics and having a lower max throughput. ReceiveMode *statsd.ReceivingMode `json:"receive_mode" toml:"receive_mode" xml:"receive_mode,attr" yaml:"receive_mode"` // ChannelModeBufferSize is the size of the channel holding incoming metrics ChannelModeBufferSize *int `` /* 131-byte string literal not displayed */ // AggregationFlushInterval is the interval for the aggregator to flush metrics AggregationFlushInterval *time.Duration `` /* 139-byte string literal not displayed */ }
Config defines the data needed to store metrics in Datadog.
type Datadog ¶
type Datadog struct { *Config `json:"datadog" toml:"datadog" xml:"datadog" yaml:"datadog"` // contains filtered or unexported fields }
Datadog allows the data to be context aware with configuration
type DatadogUnifi ¶
type DatadogUnifi struct { Collector poller.Collect LastCheck time.Time *Datadog // contains filtered or unexported fields }
DatadogUnifi is returned by New() after you provide a Config.
func (*DatadogUnifi) DebugOutput ¶
func (u *DatadogUnifi) DebugOutput() (bool, error)
func (*DatadogUnifi) Enabled ¶
func (u *DatadogUnifi) Enabled() bool
func (*DatadogUnifi) LogDatadogReport ¶
func (u *DatadogUnifi) LogDatadogReport(r *Report)
LogDatadogReport writes a log message after exporting to Datadog.
func (*DatadogUnifi) LogDebugf ¶
func (u *DatadogUnifi) LogDebugf(msg string, v ...any)
LogDebugf logs a debug message.
func (*DatadogUnifi) LogErrorf ¶
func (u *DatadogUnifi) LogErrorf(msg string, v ...any)
LogErrorf logs an error message.
func (*DatadogUnifi) PollController ¶
func (u *DatadogUnifi) PollController()
PollController runs forever, polling UniFi and pushing to Datadog This is started by Run() or RunBoth() after everything is validated.
func (*DatadogUnifi) ReportMetrics ¶
ReportMetrics batches all device and client data into datadog data points. Call this after you've collected all the data you care about. Returns an error if datadog statsd calls fail, otherwise returns a report.
type Report ¶
type Report struct { Metrics *poller.Metrics Events *poller.Events Errors []error Counts *Counts Start time.Time End time.Time Elapsed time.Duration Collector poller.Collect Total int Fields int // contains filtered or unexported fields }
Report is a will report the current collection run data.