Documentation
¶
Index ¶
- type File
- type Fingerprinter
- func (f *Fingerprinter) ComputeFingerprint(file *File) (*types.Fingerprint, error)
- func (f *Fingerprinter) ComputeFingerprintFromConfig(filepath string, fingerprintConfig *types.FingerprintConfig) (*types.Fingerprint, error)
- func (f *Fingerprinter) GetFingerprintConfig() *types.FingerprintConfig
- func (f *Fingerprinter) IsFingerprintingEnabled() bool
- func (f *Fingerprinter) ShouldFileFingerprint(file *File) bool
- type Tailer
- func (t *Tailer) DidRotate() (bool, error)
- func (t *Tailer) DidRotateViaFingerprint(fingerprinter *Fingerprinter) (bool, error)
- func (t *Tailer) GetDetectedPattern() *regexp.Regexp
- func (t *Tailer) GetId() string
- func (t *Tailer) GetInfo() *status.InfoRegistry
- func (t *Tailer) GetType() string
- func (t *Tailer) Identifier() string
- func (t *Tailer) IsFinished() bool
- func (t *Tailer) NewRotatedTailer(file *File, outputChan chan *message.Message, ...) *Tailer
- func (t *Tailer) ReplaceSource(newSource *sources.LogSource)
- func (t *Tailer) Source() *sources.LogSource
- func (t *Tailer) Start(offset int64, whence int) error
- func (t *Tailer) StartFromBeginning() error
- func (t *Tailer) Stop()
- func (t *Tailer) StopAfterFileRotation()
- type TailerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { // Path contains the path to the file which should be tailed. Path string // IsWildcardPath is set to true when the File has been discovered // in a directory with wildcard(s) in the configuration. IsWildcardPath bool // Source is the ReplaceableSource that led to this File. Source *sources.ReplaceableSource }
File represents a file to tail
func (*File) GetScanKey ¶
GetScanKey returns a key used by the scanner to index the scanned file. The string uniquely identifies this File, even if sources for multiple containers use the same Path.
func (*File) Identifier ¶
type Fingerprinter ¶
type Fingerprinter struct { FingerprintConfig types.FingerprintConfig // contains filtered or unexported fields }
Fingerprinter is a struct that contains the fingerprinting configuration
func NewFingerprinter ¶
func NewFingerprinter(fingerprintEnabled bool, fingerprintConfig types.FingerprintConfig) *Fingerprinter
NewFingerprinter creates a new Fingerprinter with the given configuration
func (*Fingerprinter) ComputeFingerprint ¶
func (f *Fingerprinter) ComputeFingerprint(file *File) (*types.Fingerprint, error)
ComputeFingerprint computes the fingerprint for the given file path
func (*Fingerprinter) ComputeFingerprintFromConfig ¶
func (f *Fingerprinter) ComputeFingerprintFromConfig(filepath string, fingerprintConfig *types.FingerprintConfig) (*types.Fingerprint, error)
ComputeFingerprintFromConfig computes the fingerprint for the given file path using a specific config
func (*Fingerprinter) GetFingerprintConfig ¶
func (f *Fingerprinter) GetFingerprintConfig() *types.FingerprintConfig
GetFingerprintConfig returns the fingerprint configuration
func (*Fingerprinter) IsFingerprintingEnabled ¶
func (f *Fingerprinter) IsFingerprintingEnabled() bool
IsFingerprintingEnabled returns whether or not our configuration has checksum fingerprinting enabled
func (*Fingerprinter) ShouldFileFingerprint ¶
func (f *Fingerprinter) ShouldFileFingerprint(file *File) bool
ShouldFileFingerprint returns whether or not a given file should be fingerprinted to detect rotation and truncation
type Tailer ¶
type Tailer struct { CapacityMonitor *metrics.CapacityMonitor // contains filtered or unexported fields }
Tailer tails a file, decodes the messages it contains, and passes them to a supplied output channel for further processing.
Operational Overview ¶
Tailers have three components, organized as a pipeline. The first, readForever, polls the file, trying to read more data. That data is passed to the second component, the decoder. The decoder produces decoder.Messages, which are passed to the third component, forwardMessages. This component translates the decoder.Messages into message.Messages and sends them to the tailer's output channel.
func NewTailer ¶
func NewTailer(opts *TailerOptions) *Tailer
NewTailer returns an initialized Tailer, read to be started.
The resulting Tailer will read from the given `file`, decode the content with the given `decoder`, and send the resulting log messages to outputChan. The Tailer takes ownership of the decoder and will start and stop it as necessary.
The Tailer must poll for content in the file. The `sleepDuration` parameter specifies how long the tailer should wait between polls.
func (*Tailer) DidRotate ¶
DidRotate returns true if the file has been log-rotated.
On *nix, when a log rotation occurs, the file can be either: - renamed and recreated - removed and recreated - truncated
func (*Tailer) DidRotateViaFingerprint ¶
func (t *Tailer) DidRotateViaFingerprint(fingerprinter *Fingerprinter) (bool, error)
DidRotateViaFingerprint returns true if the file has been log-rotated via fingerprint.
On *nix, when a log rotation occurs, the file can be either: - renamed and recreated - removed and recreated - truncated
func (*Tailer) GetDetectedPattern ¶
GetDetectedPattern returns the decoder's detected pattern.
func (*Tailer) GetInfo ¶
func (t *Tailer) GetInfo() *status.InfoRegistry
func (*Tailer) Identifier ¶
Identifier returns a string that identifies this tailer in the registry.
func (*Tailer) IsFinished ¶
IsFinished returns true if the tailer has flushed all messages to the output channel, either because it has been stopped or because of an error reading from the input file.
func (*Tailer) NewRotatedTailer ¶
func (t *Tailer) NewRotatedTailer( file *File, outputChan chan *message.Message, capacityMonitor *metrics.CapacityMonitor, decoder *decoder.Decoder, info *status.InfoRegistry, tagAdder tag.EntityTagAdder, fingerprint *logstypes.Fingerprint, registry auditor.Registry, ) *Tailer
NewRotatedTailer creates a new tailer that replaces this one, writing messages to a new channel and using an updated file and decoder.
func (*Tailer) ReplaceSource ¶
ReplaceSource replaces the current source
func (*Tailer) StartFromBeginning ¶
StartFromBeginning is a shortcut to start the tailer at the beginning of the file.
func (*Tailer) Stop ¶
func (t *Tailer) Stop()
Stop stops the tailer and returns only after all in-flight messages have been flushed to the output channel.
func (*Tailer) StopAfterFileRotation ¶
func (t *Tailer) StopAfterFileRotation()
StopAfterFileRotation prepares the tailer to stop after a timeout to finish reading its file that has been log-rotated
type TailerOptions ¶
type TailerOptions struct { OutputChan chan *message.Message // Required File *File // Required SleepDuration time.Duration // Required Decoder *decoder.Decoder // Required Info *status.InfoRegistry // Required Rotated bool // Optional TagAdder tag.EntityTagAdder // Required Fingerprint *logstypes.Fingerprint //Optional Registry auditor.Registry //Required CapacityMonitor *metrics.CapacityMonitor // Required }
TailerOptions holds all possible parameters that NewTailer requires in addition to optional parameters that can be optionally passed into. This can be used for more optional parameters if required in future