collector

package
v0.0.0-...-5abfbfe Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package collector provides functions to collect statistics about queries, filters and more

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

type Collector interface {
	// GetEntries returns a slice of query stats which
	// the collector currently has stored in memory
	GetEntries() ([]Entry, error)

	// AddEntry adds a new query entry to the
	// collector
	AddEntry(Entry) error

	// FlushEntries flushes in-memory entries
	// via the store interface (to disk)
	FlushEntries() error

	// Run runs the flush interval
	Run()
}

Collector describes an interface which is able to collect stats about queries, filters and more. The collector first stores this data in memory. At every persistence interval this data gets persisted via the CollectorStore interface

type DefaultCollector

type DefaultCollector struct {
	Store Store

	Interval   time.Duration
	LastFlush  time.Time
	MaxEntries int
	Anonymize  bool
	Enabled    bool
	// contains filtered or unexported fields
}

func NewCollector

func NewCollector(opt config.CollectorOptions) *DefaultCollector

func (*DefaultCollector) AddEntry

func (c *DefaultCollector) AddEntry(entry Entry) error

func (*DefaultCollector) FlushEntries

func (c *DefaultCollector) FlushEntries() error

func (*DefaultCollector) GetEntries

func (c *DefaultCollector) GetEntries() ([]Entry, error)

func (*DefaultCollector) Run

func (c *DefaultCollector) Run()

type DefaultStore

type DefaultStore struct {
}

DefaultStore discards flushed entries

func NewStore

func NewStore() *DefaultStore

func (*DefaultStore) Prepare

func (s *DefaultStore) Prepare() error

func (*DefaultStore) StoreEntries

func (s *DefaultStore) StoreEntries(_ []Entry) error

type Entry

type Entry struct {
	ID            string
	Question      dns.Question
	Answer        []rr.RR
	QueryTime     time.Duration
	ClientIP      net.IP
	AppliedFilter string
	Filtered      bool
	Cached        bool
}

func NewCachedEntry

func NewCachedEntry(question dns.Question, answer []rr.RR, queryTime time.Duration, ip net.IP) Entry

func NewEntry

func NewEntry(question dns.Question, answer []rr.RR, queryTime time.Duration, ip net.IP) Entry

func NewFilteredEntry

func NewFilteredEntry(question dns.Question, answer []rr.RR, queryTime time.Duration, ip net.IP) Entry

type MySQLStore

type MySQLStore struct {
	// contains filtered or unexported fields
}

MySQLStore stores flushed entries to a MySLQ / MariaDB database

func (*MySQLStore) StoreEntries

func (s *MySQLStore) StoreEntries(entries []Entry) error

type Store

type Store interface {
	// StoreEntries stores a slice of entries
	StoreEntries([]Entry) error

	// Prepare prepares the backend (if needed)
	Prepare() error
}

Store defines an interface to flush in-memory entries to persist via a backend

Jump to

Keyboard shortcuts

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