observer

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Define a counter metric for data event statistics
	DataEventStats = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace:   consts.MetricsNamespace,
		Name:        "data_events_total",
		Help:        "The number of data events by type. For internal use only.",
		ConstLabels: nil,
	}, []string{"event"})

	DataEventSizeHist = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace:   consts.MetricsNamespace,
		Name:        "data_event_size",
		Help:        "The size of received data events.",
		Buckets:     prometheus.LinearBuckets(1000, 2000, 20),
		ConstLabels: nil,
	}, []string{"op"})
)
View Source
var DataEventTypeStrings = map[DataEventType]string{
	DataEventReceived:   "Received",
	DataEventAdded:      "Added",
	DataEventAppended:   "Appended",
	DataEventMatched:    "Matched",
	DataEventNotMatched: "NotMatched",
	DataEventBad:        "Bad",
}

Functions

func AllListeners

func AllListeners(msg notify.Message)

func DataAdd added in v0.9.0

func DataAdd(id dataapi.DataEventId, msgData []byte) error

func DataEventMetricInc added in v0.11.0

func DataEventMetricInc(event DataEventType)

Increment a data event metric for an event type and location

func DataEventMetricSizeBad added in v0.11.0

func DataEventMetricSizeBad(size uint32)

func DataEventMetricSizeOk added in v0.11.0

func DataEventMetricSizeOk(size uint32)

func DataGet added in v0.9.0

func DataGet(desc dataapi.DataEventDesc) ([]byte, error)

func DataPurge added in v0.9.0

func DataPurge()

func GetSensorManager added in v1.0.0

func GetSensorManager() *sensors.Manager

func HandlePerfData added in v0.8.3

func HandlePerfData(data []byte) (byte, []Event, *HandlePerfError)

HandlePerfData returns the events from raw bytes NB: It is made public so that it can be used in testing.

func InitDataCache added in v0.9.0

func InitDataCache(size int) error

func InitMetrics added in v0.11.0

func InitMetrics(registry *prometheus.Registry)

func NewBPFCollector added in v1.0.0

func NewBPFCollector() prometheus.Collector

func NewBPFZeroCollector added in v1.1.0

func NewBPFZeroCollector() prometheus.Collector

func RegisterEventHandlerAtInit

func RegisterEventHandlerAtInit(ev uint8, handler func(r *bytes.Reader) ([]Event, error))

func RemovePrograms

func RemovePrograms(bpfDir string)

func RemoveSensors added in v1.0.0

func RemoveSensors(ctx context.Context)

func ResetSensorManager added in v1.0.0

func ResetSensorManager()

ResetSensorManager resets the global sensorManager variable to nil. Intended only for testing.

func SetSensorManager added in v1.0.0

func SetSensorManager(sm *sensors.Manager) error

Types

type Channel

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

Channel is a Listener that gob encodes events and sends them to a network connection.

func NewChannel

func NewChannel(conn net.Conn) *Channel

NewChannel initializes Channel.

func (Channel) Close

func (o Channel) Close() error

Close implements Listener.Notify.

func (Channel) Notify

func (o Channel) Notify(msg interface{}) error

Notify implements Listener.Notify.

type DataEventOp added in v1.1.0

type DataEventOp int
const (
	DataEventOpOk DataEventOp = iota
	DataEventOpBad
)

func (DataEventOp) String added in v1.1.0

func (e DataEventOp) String() string

type DataEventType added in v0.11.0

type DataEventType int
const (
	DataEventReceived DataEventType = iota
	DataEventAdded
	DataEventAppended
	DataEventMatched
	DataEventNotMatched
	DataEventBad
)

type Event

type Event notify.Message

func HandleData added in v0.9.0

func HandleData(r *bytes.Reader) ([]Event, error)

type HandlePerfError added in v1.1.0

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

func (*HandlePerfError) Error added in v1.1.0

func (e *HandlePerfError) Error() string

func (*HandlePerfError) Unwrap added in v1.1.0

func (e *HandlePerfError) Unwrap() error

type Listener

type Listener interface {
	// Notify gets called for each events from ObserverKprobe.
	Notify(msg notify.Message) error

	// Close the listener.
	io.Closer
}

Listener defines the interface to receive events from Observer. Listeners will merge and complete out-of-order events before they're passed to human-readable sinks such as the printer or GRPC encoder.

type Observer

type Observer struct {
	PerfConfig *bpf.PerfEventConfig
	// contains filtered or unexported fields
}

Observer represents the link between the BPF perf ring and the listeners. It manages the perf ring and receive events from it. It ensures that the BPF event we are receiving from the kernel is complete. The listeners are notified of their corresponding events.

func NewObserver

func NewObserver() *Observer

func (*Observer) AddListener

func (k *Observer) AddListener(listener Listener)

func (*Observer) InitSensorManager

func (k *Observer) InitSensorManager(waitChan chan struct{}) error

InitSensorManager starts the sensor controller

func (*Observer) LogPinnedBpf added in v0.9.0

func (k *Observer) LogPinnedBpf(observerDir string)

Log Active pinned BPF resources

func (*Observer) PrintStats

func (k *Observer) PrintStats()

func (*Observer) ReadErrorEvents added in v0.8.4

func (k *Observer) ReadErrorEvents() uint64

func (*Observer) ReadLostEvents added in v0.8.4

func (k *Observer) ReadLostEvents() uint64

func (*Observer) ReadReceivedEvents added in v0.8.4

func (k *Observer) ReadReceivedEvents() uint64

func (*Observer) Remove

func (k *Observer) Remove()

func (*Observer) RemoveListener

func (k *Observer) RemoveListener(listener Listener)

func (*Observer) RemovePrograms

func (k *Observer) RemovePrograms()

func (*Observer) RunEvents added in v0.11.0

func (k *Observer) RunEvents(stopCtx context.Context, ready func()) error

func (*Observer) Start

func (k *Observer) Start(ctx context.Context) error

Start starts the observer

func (*Observer) UpdateRuntimeConf

func (k *Observer) UpdateRuntimeConf(bpfDir string) error

UpdateRuntimeConf() Gathers information about Tetragon runtime environment and updates BPF map TetragonConfMap

The observer needs to do this to discover and properly operate on the right cgroup context. Use this function in your tests to allow Pod and Containers association to work.

The environment and cgroup configuration discovery may fail for several reasons, in such cases errors will be logged. On errors we also print a warning that advanced Cgroups tracking will be disabled which might affect process association with kubernetes pods and containers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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