Documentation
¶
Index ¶
- Constants
- func CleanLabels(labels map[string]string) map[string]string
- type Client
- type Config
- type LogStream
- type Logs
- type Loki
- func (l *Loki) DebugOutput() (bool, error)
- func (l *Loki) Enabled() bool
- func (l *Loki) LogDebugf(msg string, v ...any)
- func (l *Loki) LogErrorf(msg string, v ...any)
- func (l *Loki) Logf(msg string, v ...any)
- func (l *Loki) NewReport(start time.Time) *Report
- func (l *Loki) PollController()
- func (l *Loki) ProcessEvents(report *Report, events *poller.Events) error
- func (l *Loki) Run(collect poller.Collect) error
- func (l *Loki) ValidateConfig() error
- type Report
- func (r *Report) Alarm(event *unifi.Alarm, logs *Logs)
- func (r *Report) Anomaly(event *unifi.Anomaly, logs *Logs)
- func (r *Report) Event(event *unifi.Event, logs *Logs)
- func (r *Report) IDS(event *unifi.IDS, logs *Logs)
- func (r *Report) ProcessEventLogs(events *poller.Events) *Logs
- func (r *Report) String() string
Constants ¶
const ( // InputName is the name of plugin that gives us data. InputName = "unifi" // PluginName is the name of this plugin. PluginName = "loki" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client holds the http client for contacting Loki.
func (*Client) NewRequest ¶
NewRequest creates the http request based on input data.
type Config ¶
type Config struct {
Disable bool `json:"disable" toml:"disable" xml:"disable" yaml:"disable"`
VerifySSL bool `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl"`
URL string `json:"url" toml:"url" xml:"url" yaml:"url"`
Username string `json:"user" toml:"user" xml:"user" yaml:"user"`
Password string `json:"pass" toml:"pass" xml:"pass" yaml:"pass"`
TenantID string `json:"tenant_id" toml:"tenant_id" xml:"tenant_id" yaml:"tenant_id"`
Interval cnfg.Duration `json:"interval" toml:"interval" xml:"interval" yaml:"interval"`
Timeout cnfg.Duration `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"`
}
Config is the plugin's input data.
type LogStream ¶
type LogStream struct {
Labels map[string]string `json:"stream"` // "the file name"
Entries [][]string `json:"values"` // "the log lines"
}
LogStream contains a stream of logs (like a log file). This app uses one stream per log entry because each log may have different labels.
type Logs ¶
type Logs struct {
Streams []LogStream `json:"streams"` // "multiple files"
}
Logs is the main logs-holding structure. This is the Loki-output format.
type Loki ¶
type Loki struct {
Collect poller.Collect
*Config `json:"loki" toml:"loki" xml:"loki" yaml:"loki"`
// contains filtered or unexported fields
}
Loki is the main library struct. This satisfies the poller.Output interface.
func (*Loki) DebugOutput ¶
func (*Loki) PollController ¶
func (l *Loki) PollController()
PollController runs forever, polling UniFi for events and pushing them to Loki. This is started by Run().
func (*Loki) ProcessEvents ¶
ProcessEvents offloads some of the loop from PollController.
func (*Loki) ValidateConfig ¶
ValidateConfig sets initial "last" update time. Also creates an http client, makes sure URL is sane, and sets interval within min/max limits.
type Report ¶
Report is the temporary data generated by processing events.
func (*Report) ProcessEventLogs ¶
ProcessEventLogs loops the event Logs, matches the interface type, calls the appropriate method for the data, and compiles the Logs into a Loki format. This runs once per interval, if there was no collection error.