eventhandler

package
v1.3.191 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package eventhandler watches for Kubernetes Event objects and hands them off to Agent's Logs subsystem (embedded promtail)

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	SendTimeout:    60,
	CachePath:      "./.eventcache/eventhandler.cache",
	LogsInstance:   "default",
	InformerResync: 120,
	FlushInterval:  10,
}

DefaultConfig sets defaults for Config

Functions

This section is empty.

Types

type Config

type Config struct {
	// Eventhandler hands watched events off to promtail using a promtail
	// client channel. This parameter configures how long to wait (in seconds) on the channel
	// before abandoning and moving on.
	SendTimeout int `yaml:"send_timeout,omitempty"`
	// Configures the path to a kubeconfig file. If not set, will fall back to using
	// an in-cluster config. If this fails, will fall back to checking the user's home
	// directory for a kubeconfig.
	KubeconfigPath string `yaml:"kubeconfig_path,omitempty"`
	// Path to a cache file that will store the last timestamp for a shipped event and events
	// shipped for that timestamp. Used to prevent double-shipping on integration restart.
	CachePath string `yaml:"cache_path,omitempty"`
	// Name of logs subsystem instance to hand log entries off to.
	LogsInstance string `yaml:"logs_instance,omitempty"`
	// K8s informer resync interval (seconds). You should use defaults here unless you are
	// familiar with K8s informers.
	InformerResync int `yaml:"informer_resync,omitempty"`
	// The integration will flush the last event shipped out to disk every flush_interval seconds.
	FlushInterval int `yaml:"flush_interval,omitempty"`
	// If you would like to limit events to a given namespace, use this parameter.
	Namespace string `yaml:"namespace,omitempty"`
}

Config configures the eventhandler integration

func (*Config) ApplyDefaults

func (c *Config) ApplyDefaults(globals integrations.Globals) error

ApplyDefaults applies runtime-specific defaults to c

func (*Config) Identifier

func (c *Config) Identifier(globals integrations.Globals) (string, error)

Identifier uniquely identifies this instance of Config

func (*Config) Name

func (c *Config) Name() string

Name returns the name of the integration that this config represents

func (*Config) NewIntegration

func (c *Config) NewIntegration(l log.Logger, globals integrations.Globals) (integrations.Integration, error)

NewIntegration converts this config into an instance of an integration.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler for Config

type EventHandler

type EventHandler struct {
	LogsClient    *logs.Logs
	LogsInstance  string
	Log           log.Logger
	CachePath     string
	LastEvent     *ShippedEvents
	InitEvent     *ShippedEvents
	EventInformer cache.SharedIndexInformer
	SendTimeout   time.Duration

	sync.Mutex
	// contains filtered or unexported fields
}

EventHandler watches for Kubernetes Event objects and hands them off to Agent's logs subsystem (embedded promtail).

func (*EventHandler) RunIntegration

func (eh *EventHandler) RunIntegration(ctx context.Context) error

RunIntegration runs the eventhandler integration

type ShippedEvents

type ShippedEvents struct {
	// shipped event's timestamp
	Timestamp time.Time `json:"ts"`
	// map of event RVs (resource versions) already "shipped" (handed off) for this timestamp.
	// this is to handle the case of a timestamp having multiple events,
	// which happens quite frequently.
	RvMap map[string]struct{} `json:"resourceVersion"`
}

ShippedEvents stores a timestamp and map of event ResourceVersions shipped for that timestamp. Used to avoid double-shipping events upon restart.

Jump to

Keyboard shortcuts

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