common

package
v0.0.0-...-09c541f Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ImageConfigQPS is the maximum qps for image client
	ImageConfigQPS = 10
	// ImageConfigBurst is the maximum burst for image client
	ImageConfigBurst = 10
)

Variables

This section is empty.

Functions

func CollectLogsFromContainers

func CollectLogsFromContainers(
	ctx context.Context,
	coreClient v1.CoreV1Interface,
	containersFilter LogContainersFilter,
	messagesFilter LogMessagesFilter,
	buildLogFileName func(namespace string, podName string, containerName string) string,
) ([]record.Record, error)

CollectLogsFromContainers collects logs from containers

  • containerFilter allows you to specify
  • namespace in which to search for pods
  • labelSelector to filter pods by their labels (keep empty to not filter)
  • containerNameRegexFilter to filter containers in the pod (keep empty to not filter)
  • maxNamespaceContainers to limit the containers in the given namespace (keep empty to not limit)
  • logMessagesFilter allows you to specify
  • messagesToSearch to filter the logs by substrings (case-insensitive) or regex (add `(?i)` in the beginning to make search case-insensitive). Leave nil to not filter.
  • regexSearch which makes messagesToSearch regex patterns, so you can accomplish more complicated search
  • sinceSeconds which sets the moment to fetch the logs from (current time - sinceSeconds)
  • limitBytes which sets the maximum amount of logs that can be fetched
  • tailLines which sets the maximum amount of log lines from the end that should be fetched
  • buildLogFileName is the function returning filename for the current log, if nil, the default implementation is used

Default location of the logs is `config/pod/{namespace}/logs/{podName}/errors.log`,

you can override it with buildLogFileName

func FilterLogFromScanner

func FilterLogFromScanner(scanner *bufio.Scanner, messagesToSearch []string, regexSearch bool,
	cb func(lines []string) []string) (string, error)

FilterLogFromScanner filters the desired messages from the log

Types

type LogContainersFilter

type LogContainersFilter struct {
	Namespace                string
	LabelSelector            string
	FieldSelector            string
	ContainerNameRegexFilter string
	MaxNamespaceContainers   int
}

LogContainersFilter allows you to filter containers

type LogMessagesFilter

type LogMessagesFilter struct {
	MessagesToSearch []string
	IsRegexSearch    bool
	SinceSeconds     int64
	LimitBytes       int64
	TailLines        int64
	Previous         bool
}

LogMessagesFilter allows you to filter messages

Jump to

Keyboard shortcuts

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