pilot

package
v0.0.0-...-e0af774 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILEBEAT_EXEC_CMD  = "/usr/bin/filebeat"
	FILEBEAT_REGISTRY  = "/var/lib/filebeat/registry"
	FILEBEAT_BASE_CONF = "/etc/filebeat"
	FILEBEAT_CONF_DIR  = FILEBEAT_BASE_CONF + "/prospectors.d"
	FILEBEAT_CONF_FILE = FILEBEAT_BASE_CONF + "/filebeat.yml"

	DOCKER_SYSTEM_PATH  = "/var/lib/docker/"
	KUBELET_SYSTEM_PATH = "/var/lib/kubelet/"

	ENV_FILEBEAT_OUTPUT = "FILEBEAT_OUTPUT"
)

Global variables for FilebeatPiloter

View Source
const (
	FLUENTD_EXEC_CMD  = "/usr/bin/fluentd"
	FLUENTD_BASE_CONF = "/etc/fluentd"
	FLUENTD_CONF_DIR  = FLUENTD_BASE_CONF + "/conf.d"
	FLUENTD_CONF_FILE = FLUENTD_BASE_CONF + "/fluentd.conf"
	FLUENTD_PLUGINS   = FLUENTD_BASE_CONF + "/plugins"

	ENV_FLUENTD_OUTPUT = "FLUENTD_OUTPUT"
	ENV_FLUENTD_WORKER = "FLUENTD_WORKER"
)

Global variables for FluentdPiloter

View Source
const (
	ENV_PILOT_LOG_PREFIX     = "PILOT_LOG_PREFIX"
	ENV_PILOT_CREATE_SYMLINK = "PILOT_CREATE_SYMLINK"
	ENV_LOGGING_OUTPUT       = "LOGGING_OUTPUT"

	ENV_SERVICE_LOGS_TEMPL                  = "%s_logs_"
	ENV_SERVICE_LOGS_CUSTOME_CONFIG_TEMPL   = "%s_logs_custom_config"
	LABEL_SERVICE_LOGS_TEMPL                = "%s.logs."
	LABEL_SERVICE_LOGS_CUSTOME_CONFIG_TEMPL = "%s.logs.custom.config"
	LABEL_PROJECT_SWARM_MODE                = "com.docker.stack.namespace"
	LABEL_PROJECT                           = "com.docker.compose.project"
	LABEL_SERVICE                           = "com.docker.compose.service"
	LABEL_SERVICE_SWARM_MODE                = "com.docker.swarm.service.name"
	LABEL_K8S_POD_NAMESPACE                 = "io.kubernetes.pod.namespace"
	LABEL_K8S_CONTAINER_NAME                = "io.kubernetes.container.name"
	LABEL_POD                               = "io.kubernetes.pod.name"
	SYMLINK_LOGS_BASE                       = "/acs/log/"

	ERR_ALREADY_STARTED = "already started"
)

Global variables

View Source
const (
	ENV_PILOT_TYPE = "PILOT_TYPE"

	PILOT_FILEBEAT = "filebeat"
	PILOT_FLUENTD  = "fluentd"
)

Global variables for piloter

Variables

This section is empty.

Functions

func Convert

func Convert(info *LogInfoNode) (map[string]string, error)

Convert convert node info to map

func CustomConfig

func CustomConfig(name string, customConfigs map[string]string, logConfig *LogConfig)

CustomConfig custom config

func ReadFile

func ReadFile(path string, separator string) ([]string, error)

ReadFile return string list separated by separator

func Register

func Register(format string, converter FormatConverter)

Register format converter instance

func Run

func Run(templ string, baseDir string) error

Run start log pilot

Types

type Config

type Config struct {
	Paths []string `config:"paths"`
}

Config contains all log paths

type FileInode

type FileInode struct {
	Inode  uint64 `json:"inode,"`
	Device uint64 `json:"device,"`
}

FileInode identify a unique log file

type FilebeatPiloter

type FilebeatPiloter struct {
	// contains filtered or unexported fields
}

FilebeatPiloter for filebeat plugin

func (*FilebeatPiloter) GetBaseConf

func (p *FilebeatPiloter) GetBaseConf() string

GetBaseConf returns plugin root directory

func (*FilebeatPiloter) GetConfHome

func (p *FilebeatPiloter) GetConfHome() string

GetConfHome returns configuration directory

func (*FilebeatPiloter) GetConfPath

func (p *FilebeatPiloter) GetConfPath(container string) string

GetConfPath returns log configuration path

func (*FilebeatPiloter) Name

func (p *FilebeatPiloter) Name() string

Name returns plugin name

func (*FilebeatPiloter) OnDestroyEvent

func (p *FilebeatPiloter) OnDestroyEvent(container string) error

OnDestroyEvent watching destroy event

func (*FilebeatPiloter) Reload

func (p *FilebeatPiloter) Reload() error

Reload reload configuration file

func (*FilebeatPiloter) Start

func (p *FilebeatPiloter) Start() error

Start starting and watching filebeat process

func (*FilebeatPiloter) Stop

func (p *FilebeatPiloter) Stop() error

Stop log collection

type FluentdPiloter

type FluentdPiloter struct {
	// contains filtered or unexported fields
}

FluentdPiloter for fluentd plugin

func (*FluentdPiloter) GetBaseConf

func (p *FluentdPiloter) GetBaseConf() string

GetBaseConf returns plugin root directory

func (*FluentdPiloter) GetConfHome

func (p *FluentdPiloter) GetConfHome() string

GetConfHome returns configuration directory

func (*FluentdPiloter) GetConfPath

func (p *FluentdPiloter) GetConfPath(container string) string

GetConfPath returns log configuration path

func (*FluentdPiloter) Name

func (p *FluentdPiloter) Name() string

Name returns plugin name

func (*FluentdPiloter) OnDestroyEvent

func (p *FluentdPiloter) OnDestroyEvent(container string) error

OnDestroyEvent watching destroy event

func (*FluentdPiloter) Reload

func (p *FluentdPiloter) Reload() error

Reload reload configuration file

func (*FluentdPiloter) Start

func (p *FluentdPiloter) Start() error

Start starting and watching fluentd process

func (*FluentdPiloter) Stop

func (p *FluentdPiloter) Stop() error

Stop log collection

type FormatConverter

type FormatConverter func(info *LogInfoNode) (map[string]string, error)

FormatConverter converts node info to map

type LogConfig

type LogConfig struct {
	Name         string
	HostDir      string
	ContainerDir string
	Format       string
	FormatConfig map[string]string
	File         string
	Tags         map[string]string
	Target       string
	EstimateTime bool
	Stdout       bool

	CustomFields  map[string]string
	CustomConfigs map[string]string
}

LogConfig log configuration

type LogInfoNode

type LogInfoNode struct {
	// contains filtered or unexported fields
}

LogInfoNode node info

type Pilot

type Pilot struct {
	// contains filtered or unexported fields
}

Pilot entry point

func New

func New(tplStr string, baseDir string) (*Pilot, error)

New returns a log pilot instance

type Piloter

type Piloter interface {
	Name() string

	Start() error
	Reload() error
	Stop() error

	GetBaseConf() string
	GetConfHome() string
	GetConfPath(container string) string

	OnDestroyEvent(container string) error
}

Piloter interface for piloter

func NewFilebeatPiloter

func NewFilebeatPiloter(baseDir string) (Piloter, error)

NewFilebeatPiloter returns a FilebeatPiloter instance

func NewFluentdPiloter

func NewFluentdPiloter() (Piloter, error)

NewFluentdPiloter returns a FluentdPiloter instance

func NewPiloter

func NewPiloter(baseDir string) (Piloter, error)

NewPiloter instantiates a new piloter

type RegistryState

type RegistryState struct {
	Source      string        `json:"source"`
	Offset      int64         `json:"offset"`
	Timestamp   time.Time     `json:"timestamp"`
	TTL         time.Duration `json:"ttl"`
	Type        string        `json:"type"`
	FileStateOS FileInode
}

RegistryState represents log offsets

type SimpleConverter

type SimpleConverter struct {
	// contains filtered or unexported fields
}

SimpleConverter simple format converter

Jump to

Keyboard shortcuts

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