tail

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Defined as <DBName>:<Table>
	AdxMonLogDestinationAnnotation = "adx-mon/log-destination"
	// Defined as comma separated parser names
	AdxMonLogParsersAnnotation = "adx-mon/log-parsers"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileTailTarget

type FileTailTarget struct {
	// FilePath is the file to tail.
	FilePath string

	// LogType is the format of the log file. e.g. docker for logs written by the docker json driver.
	// This provides a mechanism to combine split lines, parse timestamps (if present), and extract a message field.
	// Defaults to plain.
	LogType sourceparse.Type

	// The destination database name. Populated into the databasename attribute of the log that can be overwritten by transforms.
	Database string

	// The destination table name. Populated into the tablename attribute of the log that can be overwritten by transforms.
	Table string

	// Parsers is a list of parsers names to apply to each line of the log file to attempt to extract fields from the message body.
	// These are run sequentially until one succeeds, or until all have been tried.
	// These are converted into parser.ParserType.
	Parsers []string

	// Resources is a map of additional resource k/v pairs to add to each log.
	Resources map[string]interface{}
}

FileTailTarget describes a file to tail, how to parse it, and the destination for the parsed logs. It is used in the list of StaticTargets in TailSourceConfig, or used in AddTarget. NOTE: If new fields are added that change during runtime (e.g. from pod metadata changing) that are sent via UpdateChan, update isTargetChanged to take this new field into account.

type PodDiscovery

type PodDiscovery struct {
	NodeName string
	// contains filtered or unexported fields
}

func NewPodDiscovery

func NewPodDiscovery(opts PodDiscoveryOpts, tailsource TailerSourceInterface) *PodDiscovery

func (*PodDiscovery) Close

func (i *PodDiscovery) Close() error

func (*PodDiscovery) OnAdd

func (i *PodDiscovery) OnAdd(obj interface{}, isInitialList bool)

OnAdd is called when an object is added. Expects a pod.

func (*PodDiscovery) OnDelete

func (i *PodDiscovery) OnDelete(obj interface{})

OnDelete is called when an object is deleted. Expects a pod.

func (*PodDiscovery) OnUpdate

func (i *PodDiscovery) OnUpdate(oldObj, newObj interface{})

OnUpdate is called when an object is updated. Expects a pod.

func (*PodDiscovery) Open

func (i *PodDiscovery) Open(ctx context.Context) error

type PodDiscoveryOpts

type PodDiscoveryOpts struct {
	NodeName         string
	PodInformer      k8s.PodInformerInterface
	StaticPodTargets []*StaticPodTargets
}

type StaticPodTargets added in v0.2.0

type StaticPodTargets struct {
	Namespace   string
	Name        string
	Labels      map[string]string
	Parsers     []string
	Destination string
}

type TailSource

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

TailSource implements the types.Source interface for tailing files.

func NewTailSource

func NewTailSource(config TailSourceConfig) (*TailSource, error)

func (*TailSource) AddTarget

func (s *TailSource) AddTarget(target FileTailTarget, updateChan <-chan FileTailTarget) error

AddTarget adds a new file to tail. updateChan is an optional channel to provide updated FileTailTarget metadata during runtime. Does not support updating FilePath or LogType.

func (*TailSource) Close

func (s *TailSource) Close() error

func (*TailSource) Name

func (s *TailSource) Name() string

func (*TailSource) Open

func (s *TailSource) Open(ctx context.Context) error

func (*TailSource) RemoveTarget

func (s *TailSource) RemoveTarget(filePath string)

RemoveTarget removes a file from being tailed. This also removes the cursor file, so this should only be called when the file is not longer expected to be tailed in the future.

type TailSourceConfig

type TailSourceConfig struct {
	StaticTargets   []FileTailTarget
	CursorDirectory string
	WorkerCreator   engine.WorkerCreatorFunc
	// TODO mkeesey - TailSource should not need to manage poddiscovery service lifecycle.
	// However, creation of TailSource happens with a create method to access store, making this
	// wiring difficult.
	PodDiscoveryOpts *PodDiscoveryOpts
}

TailSourceConfig configures TailSource.

type Tailer

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

Tailer is a specific instance of a file being tailed.

func StartTailing

func StartTailing(config TailerConfig) (*Tailer, error)

func (*Tailer) Stop

func (t *Tailer) Stop()

Stop stops the tailer and cleans up resources. Does not wait for the tailer to finish processing, to allow closing many tailers concurrently. Call Wait() after calling Stop() to wait for the tailer to finish processing.

func (*Tailer) Wait

func (t *Tailer) Wait()

Wait waits for the tailer to finish processing.

type TailerConfig

type TailerConfig struct {
	Target          FileTailTarget
	UpdateChan      <-chan FileTailTarget
	AckGenerator    func(*types.Log) func()
	WorkerCreator   engine.WorkerCreatorFunc
	CursorDirectory string
	WorkerName      string
}

type TailerSourceInterface

type TailerSourceInterface interface {
	AddTarget(target FileTailTarget, updateChan <-chan FileTailTarget) error
	RemoveTarget(target string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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