Documentation
¶
Index ¶
- Variables
- func InitLogSourceFactories(app *kingpin.Application)
- func IsWatchdogUnhealthy(ctx context.Context) bool
- func RegisterLogSourceFactory(lsf LogSourceFactory)
- type DockerClient
- type DockerLogSource
- type FileLogSource
- type KubernetesLogSource
- type LogSource
- type LogSourceCloser
- type LogSourceDefaults
- type LogSourceFactory
- type LogSourceFactoryDefaults
- type SystemdJournal
- type SystemdLogSource
Constants ¶
This section is empty.
Variables ¶
var (
SystemdNoMoreEntries = errors.New("No more journal entries") // nolint:staticcheck
)
Functions ¶
func InitLogSourceFactories ¶
func InitLogSourceFactories(app *kingpin.Application)
InitLogSourceFactories runs Init on all factories. The initialization order is arbitrary, except `fileLogSourceFactory` is always last (the fallback). The file log source must be last since it's enabled by default.
func IsWatchdogUnhealthy ¶ added in v0.16.0
IsWatchdogUnhealthy returns true if any of the log sources report being unhealthy.
func RegisterLogSourceFactory ¶
func RegisterLogSourceFactory(lsf LogSourceFactory)
RegisterLogSourceFactory can be called from module `init` functions to register factories.
Types ¶
type DockerClient ¶
type DockerClient interface {
io.Closer
ContainerLogs(context.Context, string, container.LogsOptions) (io.ReadCloser, error)
}
A DockerClient is the client interface that client.Client provides. See https://pkg.go.dev/github.com/docker/docker/client
type DockerLogSource ¶
type DockerLogSource struct {
LogSourceDefaults
// contains filtered or unexported fields
}
A DockerLogSource reads log records from the given Docker journal.
func NewDockerLogSource ¶
func NewDockerLogSource(ctx context.Context, c DockerClient, containerID string) (*DockerLogSource, error)
NewDockerLogSource returns a log source for reading Docker logs.
func (*DockerLogSource) Close ¶
func (s *DockerLogSource) Close() error
func (*DockerLogSource) Path ¶
func (s *DockerLogSource) Path() string
type FileLogSource ¶
type FileLogSource struct {
LogSourceDefaults
// contains filtered or unexported fields
}
A FileLogSource can read lines from a file.
func NewFileLogSource ¶
func NewFileLogSource(path string, config tail.Config) (*FileLogSource, error)
NewFileLogSource creates a new log source, tailing the given file.
func (*FileLogSource) Close ¶
func (s *FileLogSource) Close() error
func (*FileLogSource) Path ¶
func (s *FileLogSource) Path() string
type KubernetesLogSource ¶
type KubernetesLogSource struct {
LogSourceDefaults
// contains filtered or unexported fields
}
A KubernetesLogSource can read lines from Kubernetes pod logs.
func NewKubernetesLogSource ¶
func NewKubernetesLogSource(ctx context.Context, namespace, serviceName, containerName string, pod corev1.Pod, clientset *kubernetes.Clientset) []*KubernetesLogSource
NewKubernetesLogSource creates a new log source that reads from Kubernetes pod logs.
func (*KubernetesLogSource) Close ¶
func (s *KubernetesLogSource) Close() error
func (*KubernetesLogSource) ConstLabels ¶
func (s *KubernetesLogSource) ConstLabels() prometheus.Labels
func (*KubernetesLogSource) Path ¶
func (s *KubernetesLogSource) Path() string
func (*KubernetesLogSource) Read ¶
func (s *KubernetesLogSource) Read(ctx context.Context) (string, error)
func (*KubernetesLogSource) RemoteAddr ¶
func (s *KubernetesLogSource) RemoteAddr() string
type LogSource ¶
type LogSource interface {
// Path returns a representation of the log location.
Path() string
// Read returns the next log line. Returns `io.EOF` at the end of
// the log.
Read(context.Context) (string, error)
ConstLabels() prometheus.Labels
RemoteAddr() string
// contains filtered or unexported methods
}
A LogSource is an interface to read log lines.
type LogSourceCloser ¶
func NewLogSourceFromFactories ¶
func NewLogSourceFromFactories(ctx context.Context) ([]LogSourceCloser, error)
NewLogSourceFromFactories iterates through the factories and attempts to instantiate a log source. The first factory to return success wins.
type LogSourceDefaults ¶
type LogSourceDefaults struct{}
func (LogSourceDefaults) ConstLabels ¶
func (LogSourceDefaults) ConstLabels() prometheus.Labels
func (LogSourceDefaults) RemoteAddr ¶
func (LogSourceDefaults) RemoteAddr() string
type LogSourceFactory ¶
type LogSourceFactory interface {
// Init adds the factory's struct fields as flags in the
// application.
Init(*kingpin.Application)
// New attempts to create a new log source. This is called after
// flags have been parsed. Returning `nil, nil`, means the user
// didn't want this log source.
New(context.Context) ([]LogSourceCloser, error)
// Watchdog indicates whether this log source is unhealthy.
Watchdog(context.Context) bool
// contains filtered or unexported methods
}
A LogSourceFactory provides a repository of log sources that can be instantiated from command line flags.
type LogSourceFactoryDefaults ¶ added in v0.16.0
type LogSourceFactoryDefaults struct{}
type SystemdJournal ¶
type SystemdJournal interface {
io.Closer
AddMatch(match string) error
GetEntry() (*sdjournal.JournalEntry, error)
Next() (uint64, error)
SeekTail() error
PreviousSkip(skip uint64) (uint64, error)
Wait(timeout time.Duration) int
}
A SystemdJournal is the journal interface that sdjournal.Journal provides. See https://pkg.go.dev/github.com/coreos/go-systemd/sdjournal?tab=doc
type SystemdLogSource ¶
type SystemdLogSource struct {
LogSourceDefaults
// contains filtered or unexported fields
}
A SystemdLogSource reads log records from the given Systemd journal.
func NewSystemdLogSource ¶
func NewSystemdLogSource(j SystemdJournal, path, unit, slice string) (*SystemdLogSource, error)
NewSystemdLogSource returns a log source for reading Systemd journal entries. `unit` and `slice` provide filtering if non-empty (with `slice` taking precedence).
func (*SystemdLogSource) Close ¶
func (s *SystemdLogSource) Close() error
func (*SystemdLogSource) Path ¶
func (s *SystemdLogSource) Path() string