Documentation
¶
Index ¶
- type File
- type FingerprintConfigInfo
- type Fingerprinter
- 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) GetFingerprint() *logstypes.Fingerprint
- 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 ¶
Identifier returns a unique identifier for this file
type FingerprintConfigInfo ¶
type FingerprintConfigInfo struct {
// contains filtered or unexported fields
}
FingerprintConfigInfo holds fingerprint configuration for status display
func NewFingerprintConfigInfo ¶
func NewFingerprintConfigInfo(config *types.FingerprintConfig) *FingerprintConfigInfo
NewFingerprintConfigInfo creates a new FingerprintConfigInfo from a FingerprintConfig
func (*FingerprintConfigInfo) Info ¶
func (f *FingerprintConfigInfo) Info() []string
Info returns formatted fingerprint configuration information
func (*FingerprintConfigInfo) InfoKey ¶
func (f *FingerprintConfigInfo) InfoKey() string
InfoKey returns the key for this info This data is exposed in the status table
type Fingerprinter ¶
type Fingerprinter interface {
// ShouldFileFingerprint returns whether or not a given file should be fingerprinted to detect rotation and truncation
ShouldFileFingerprint(file *File) bool
// ComputeFingerprint computes the fingerprint for the given file path
ComputeFingerprint(file *File) (*types.Fingerprint, error)
// ComputeFingerprintFromHandle computes the fingerprint for the given os.File using the provided config
ComputeFingerprintFromHandle(osFile afero.File, fingerprintConfig *types.FingerprintConfig) (*types.Fingerprint, error)
// ComputeFingerprintFromConfig computes the fingerprint for the given file path using a specific config
ComputeFingerprintFromConfig(filepath string, fingerprintConfig *types.FingerprintConfig) (*types.Fingerprint, error)
// GetEffectiveConfigForFile returns the fingerprint configuration that applies to a file for status display purposes
GetEffectiveConfigForFile(file *File) *types.FingerprintConfig
}
Fingerprinter is an interface that defines the methods for fingerprinting files
func NewFingerprinter ¶
func NewFingerprinter(fingerprintConfig types.FingerprintConfig, opener opener.FileOpener) Fingerprinter
NewFingerprinter creates a new Fingerprinter with the given configuration
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.
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) GetFingerprint ¶
func (t *Tailer) GetFingerprint() *logstypes.Fingerprint
GetFingerprint returns the tailer's fingerprint
func (*Tailer) GetInfo ¶
func (t *Tailer) GetInfo() *status.InfoRegistry
GetInfo returns the tailer's status info registry
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, fingerprinter Fingerprinter, 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
Fingerprinter Fingerprinter // Required
Registry auditor.Registry // Required
CapacityMonitor *metrics.CapacityMonitor // Required
FileOpener opener.FileOpener // 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