Documentation ¶
Index ¶
- Variables
- func AllListeners(msg notify.Message)
- func DataAdd(id dataapi.DataEventId, msgData []byte) error
- func DataEventMetricInc(event DataEventType)
- func DataEventMetricSizeBad(size uint32)
- func DataEventMetricSizeOk(size uint32)
- func DataGet(desc dataapi.DataEventDesc) ([]byte, error)
- func DataPurge()
- func GetSensorManager() *sensors.Manager
- func HandlePerfData(data []byte) (byte, []Event, *HandlePerfError)
- func InitDataCache(size int) error
- func InitMetrics()
- func NewBPFCollector() metrics.CollectorWithInit
- func RegisterEventHandlerAtInit(ev uint8, handler func(r *bytes.Reader) ([]Event, error))
- func RegisterHealthMetrics(group metrics.Group)
- func RegisterMetrics(group metrics.Group)
- func RemoveSensors(ctx context.Context)
- func ResetSensorManager()
- func SetSensorManager(sm *sensors.Manager) error
- type Channel
- type DataEventOp
- type DataEventType
- type Event
- type HandlePerfError
- type Listener
- type Observer
- func (k *Observer) AddListener(listener Listener)
- func (k *Observer) InitSensorManager(waitChan chan struct{}) error
- func (k *Observer) LogPinnedBpf(observerDir string)
- func (k *Observer) PrintStats()
- func (k *Observer) ReadErrorEvents() uint64
- func (k *Observer) ReadLostEvents() uint64
- func (k *Observer) ReadReceivedEvents() uint64
- func (k *Observer) Remove()
- func (k *Observer) RemoveListener(listener Listener)
- func (k *Observer) RunEvents(stopCtx context.Context, ready func()) error
- func (k *Observer) Start(ctx context.Context) error
- func (k *Observer) UpdateRuntimeConf(bpfDir string) error
Constants ¶
This section is empty.
Variables ¶
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"}) )
var ( RingbufReceived = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: consts.MetricsNamespace, Subsystem: subsystem, Name: "ringbuf_events_received_total", Help: "Number of perf events Tetragon ring buffer received.", ConstLabels: nil, }) RingbufLost = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: consts.MetricsNamespace, Subsystem: subsystem, Name: "ringbuf_events_lost_total", Help: "Number of perf events Tetragon ring buffer lost.", ConstLabels: nil, }) RingbufErrors = prometheus.NewCounter(prometheus.CounterOpts{ Namespace: consts.MetricsNamespace, Subsystem: subsystem, Name: "ringbuf_errors_total", Help: "Number of errors when reading Tetragon ring buffer.", ConstLabels: nil, }) )
var DataEventTypeStrings = map[DataEventType]string{ DataEventReceived: "Received", DataEventAdded: "Added", DataEventAppended: "Appended", DataEventMatched: "Matched", DataEventNotMatched: "NotMatched", DataEventBad: "Bad", }
Functions ¶
func AllListeners ¶
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 GetSensorManager ¶ added in v1.0.0
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 InitMetrics ¶ added in v0.11.0
func InitMetrics()
func NewBPFCollector ¶ added in v1.0.0
func NewBPFCollector() metrics.CollectorWithInit
func RegisterHealthMetrics ¶ added in v1.2.0
func RegisterMetrics ¶ added in v1.2.0
func RemoveSensors ¶ added in v1.0.0
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
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.
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 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 (*Observer) InitSensorManager ¶
InitSensorManager starts the sensor controller
func (*Observer) LogPinnedBpf ¶ added in v0.9.0
Log Active pinned BPF resources
func (*Observer) PrintStats ¶
func (k *Observer) PrintStats()
func (*Observer) ReadErrorEvents ¶ added in v0.8.4
func (*Observer) ReadLostEvents ¶ added in v0.8.4
func (*Observer) ReadReceivedEvents ¶ added in v0.8.4
func (*Observer) RemoveListener ¶
func (*Observer) UpdateRuntimeConf ¶
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.