querylog

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 40 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountDropped added in v0.37.0

func CountDropped(reason DropReason, n int)

CountDropped counts n entries dropped for reason.

func LogEntryFields

func LogEntryFields(entry *LogEntry) logrus.Fields

Types

type DatabaseWriter

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

DatabaseWriter buffers entries in memory and writes them to the database in batches from a single background goroutine, so Write never waits on the database. A failed batch is retried until it's written, except for rows the database refuses; the database being unreachable at startup is retried the same way. A batch interrupted at commit may be written twice.

func NewDatabaseWriter

func NewDatabaseWriter(ctx context.Context, dbType config.QueryLogType, target string, logRetentionDays uint64,
	dbFlushPeriod time.Duration,
) (*DatabaseWriter, error)

func (*DatabaseWriter) CleanUp

func (d *DatabaseWriter) CleanUp()

func (*DatabaseWriter) Shutdown added in v0.37.0

func (d *DatabaseWriter) Shutdown(ctx context.Context) error

Shutdown stops the background goroutine and writes the pending entries, retrying until ctx ends. Entries left unwritten are dropped and counted.

func (*DatabaseWriter) Write

func (d *DatabaseWriter) Write(entry *LogEntry)

type DnstapWriter added in v0.33.0

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

func NewDnstapWriter added in v0.33.0

func NewDnstapWriter(target string, flushInterval time.Duration, instanceID string) (*DnstapWriter, error)

func (*DnstapWriter) CleanUp added in v0.33.0

func (d *DnstapWriter) CleanUp()

CleanUp implements the retention-cleanup hook of the Writer interface. dnstap is a streaming export with nothing to prune, so this is a no-op; lifecycle teardown happens in Close instead.

func (*DnstapWriter) Close added in v0.33.0

func (d *DnstapWriter) Close() error

Close signals shutdown: it stops accepting frames so the run goroutine stops and closes the socket itself. It deliberately does not touch d.writer — run owns it, and the dnstap socketWriter is not safe for a Close concurrent with an in-flight WriteFrame — and never waits on an in-flight WriteFrame, so a stuck collector connection cannot hang shutdown.

func (*DnstapWriter) Write added in v0.33.0

func (d *DnstapWriter) Write(entry *LogEntry)

type DropReason added in v0.37.0

type DropReason string

DropReason says why a query log entry was dropped instead of written.

const (
	DropReasonQueueFull  DropReason = "queue_full"  // the writer fell behind its queue
	DropReasonBufferFull DropReason = "buffer_full" // the database was slow or down for too long
	DropReasonRejected   DropReason = "rejected"    // the database refused the row
	DropReasonShutdown   DropReason = "shutdown"    // not written before blocky stopped
)

The reasons a query log entry is dropped.

type FileWriter

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

func NewCSVWriter

func NewCSVWriter(target string, perClient bool, logRetentionDays uint64) (*FileWriter, error)

func (*FileWriter) CleanUp

func (d *FileWriter) CleanUp()

CleanUp deletes old log files

func (*FileWriter) Write

func (d *FileWriter) Write(entry *LogEntry)

type LogEntry

type LogEntry struct {
	Start          time.Time
	ClientIP       string
	ClientNames    []string
	DurationMs     int64
	ResponseReason string
	ResponseType   string
	ResponseCode   string
	QuestionType   string
	QuestionName   string
	Answer         string
	BlockyInstance string
	QueryWire      []byte
	ResponseWire   []byte
	QueryTime      time.Time
	ResponseTime   time.Time
	SocketProtocol model.RequestProtocol
}

type LoggerWriter

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

func NewLoggerWriter

func NewLoggerWriter() *LoggerWriter

func (*LoggerWriter) CleanUp

func (d *LoggerWriter) CleanUp()

func (*LoggerWriter) Write

func (d *LoggerWriter) Write(entry *LogEntry)

type NoneWriter

type NoneWriter struct{}

func NewNoneWriter

func NewNoneWriter() *NoneWriter

func (*NoneWriter) CleanUp

func (d *NoneWriter) CleanUp()

func (*NoneWriter) Write

func (d *NoneWriter) Write(*LogEntry)

type Writer

type Writer interface {
	Write(entry *LogEntry)
	CleanUp()
}

Jump to

Keyboard shortcuts

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