Documentation ¶
Overview ¶
Package kubetail implements a log file tailer using the Kubernetes API.
Index ¶
- Constants
- func PrepareLabels(lset labels.Labels, defaultJob string) (res labels.Labels, err error)
- type Manager
- type Options
- type Target
- func (t *Target) ContainerName() string
- func (t *Target) DiscoveryLabels() labels.Labels
- func (t *Target) Hash() uint64
- func (t *Target) Labels() labels.Labels
- func (t *Target) LastEntry() time.Time
- func (t *Target) LastError() error
- func (t *Target) NamespacedName() types.NamespacedName
- func (t *Target) Report(time time.Time, err error)
- func (t *Target) String() string
- func (t *Target) UID() string
Constants ¶
const ( LabelPodNamespace = "__pod_namespace__" LabelPodName = "__pod_name__" LabelPodContainerName = "__pod_container_name__" LabelPodUID = "__pod_uid__" )
Internal labels which indicate what container to tail logs from.
Variables ¶
This section is empty.
Functions ¶
func PrepareLabels ¶
PrepareLabels builds a label set with default labels applied from the default label set. It validates that the input label set is valid.
The namespace of the pod to tail logs from is determined by the LabelPodNamespace label. If this label isn't present, PrepareLabels falls back to __meta_kubernetes_namespace.
The name of the pod to tail logs from is determined by the LabelPodName label. If this label isn't present, PrepareLabels falls back to __meta_kubernetes_pod_name.
The name of the container to tail logs from is determined by the LabelPodContainerName label. If this label isn't present, PrepareLabels falls back to __meta_kubernetes_pod_container_name.
Validation of lset fails if there is no label indicating the pod namespace, pod name, or container name.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
A Manager manages a set of running Tailers.
func NewManager ¶
NewManager returns a new Manager which manages a set of running tailers. Options must not be modified after passing it to a Manager.
If NewManager is called with a nil set of options, no targets will be scheduled for running until UpdateOptions is called.
func (*Manager) Stop ¶
func (m *Manager) Stop()
Stop stops the manager and all running Tailers. It blocks until all Tailers have exited.
func (*Manager) SyncTargets ¶
SyncTargets synchronizes the set of running tailers to the set specified by targets.
func (*Manager) Targets ¶
Targets returns the set of targets which are actively being tailed. Targets for tailers which have terminated are not included. The returned set of targets are deduplicated.
func (*Manager) UpdateOptions ¶
UpdateOptions updates the Options shared with all Tailers. All Tailers will be updated with the new set of Options. Options should not be modified after passing to UpdateOptions.
If newOptions is nil, all tasks will be cleared until UpdateOptions is called again with a non-nil set of options.
type Options ¶
type Options struct { // Client to use to request logs from Kubernetes. Client *kubernetes.Clientset // Handler to send discovered logs to. Handler loki.EntryHandler // Positions interface so tailers can save/restore offsets in log files. Positions positions.Positions }
Options passed to all tailers.
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target represents an individual container being tailed for logs.
func (*Target) ContainerName ¶
ContainerName returns the container name being targeted.
func (*Target) DiscoveryLabels ¶
DiscoveryLabels returns the set of original labels prior to processing or relabeling.
func (*Target) LastEntry ¶
LastEntry returns the time the most recent log line was read or when the most recent error occurred.
func (*Target) NamespacedName ¶
func (t *Target) NamespacedName() types.NamespacedName
NamespacedName returns the key of the Pod being targeted.