inputdockerlog

package
v0.0.0-...-c13075e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 18 Imported by: 5

README

gogstash input docker

Synopsis

{
	"input": [
		{
			"type": "dockerlog",

			// (optional), docker endpoint, default: "unix:///var/run/docker.sock"
			"dockerurl": "unix:///var/run/docker.sock",

			// (optional), include docker name pattern, support regular expression of golang, default: []
			"include_patterns": [],

			// (optional), exclude docker name pattern, support regular expression of golang, default: ["gogstash"]
			"exclude_patterns": ["gogstash"],

			// (optional), sincedb storage path, default: "sincedb"
			"sincepath": "sincedb",

			// (optional), in seconds, docker connection retry interval, default: 10
			"connection_retry_interval": 10

			// (optional), path of TLS cert, default: ""
			"tls_cert": "/tmp/cert.pem"

			// (optional), path of TLS key, default: ""
			"tls_cert_key": "/tmp/key.pem"

			// (optional), path of TLS CA cert, default: ""
			"tls_ca_cert": "/tmp/ca.pem"
		}
	]
}

Documentation

Index

Constants

View Source
const ModuleName = "dockerlog"

ModuleName is the name used in config file

Variables

View Source
var (
	ErrorPingFailed              = errutil.NewFactory("ping docker server failed")
	ErrorListContainerFailed     = errutil.NewFactory("list docker container failed")
	ErrorListenDockerEventFailed = errutil.NewFactory("listen docker event failed")
	ErrorInspectContainerFailed  = errutil.NewFactory("inspect container failed")
	ErrorContainerLoopRunning1   = errutil.NewFactory("container log loop running: %s")
	ErrorGetContainerInfoFailed  = errutil.NewFactory("get container info failed")
)

errors

Functions

func InitHandler

func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeInputConfig, error)

InitHandler initialize the input plugin

Types

type ContainerLogStream

type ContainerLogStream struct {
	io.Writer
	ID string
	// contains filtered or unexported fields
}

func NewContainerLogStream

func NewContainerLogStream(msgChan chan<- logevent.LogEvent, id string,
	eventExtra map[string]any, since *time.Time, logger *logrus.Logger,
	codec config.TypeCodecConfig) ContainerLogStream

func (*ContainerLogStream) Write

func (t *ContainerLogStream) Write(p []byte) (n int, err error)

type InputConfig

type InputConfig struct {
	config.InputConfig
	DockerURL               string   `json:"dockerurl"`
	IncludePatterns         []string `json:"include_patterns"`
	ExcludePatterns         []string `json:"exclude_patterns"`
	SincePath               string   `json:"sincepath"`
	StartPos                string   `json:"start_position,omitempty"` // one of ["beginning", "end"]
	ConnectionRetryInterval int      `json:"connection_retry_interval,omitempty"`
	TLSCert                 string   `json:"tls_cert,omitempty"`
	TLSCertKey              string   `json:"tls_cert_key,omitempty"`
	TLSCaCert               string   `json:"tls_ca_cert,omitempty"`
	// contains filtered or unexported fields
}

InputConfig holds the configuration json fields and internal objects

func DefaultInputConfig

func DefaultInputConfig() InputConfig

DefaultInputConfig returns an InputConfig struct with default values

func (*InputConfig) Start

func (t *InputConfig) Start(ctx context.Context, msgChan chan<- logevent.LogEvent) error

Start wraps the actual function starting the plugin

type SinceDB

type SinceDB struct {
	SinceMap map[string]*SinceFile
	// contains filtered or unexported fields
}

func NewSinceDB

func NewSinceDB(dbdir string) (sincedb *SinceDB, err error)

func (*SinceDB) Close

func (t *SinceDB) Close() (err error)

func (*SinceDB) Del

func (t *SinceDB) Del(id string) (err error)

func (*SinceDB) Get

func (t *SinceDB) Get(id string) (since *time.Time, err error)

func (*SinceDB) Open

func (t *SinceDB) Open(dbdir string) (err error)

type SinceFile

type SinceFile struct {
	Since *time.Time
	// contains filtered or unexported fields
}

func NewSinceFile

func NewSinceFile(filepath string) (sincefile *SinceFile, err error)

func (*SinceFile) Close

func (t *SinceFile) Close() (err error)

func (*SinceFile) Open

func (t *SinceFile) Open(filepath string) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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