github.com/cilium/cilium@v1.16.2/pkg/hubble/observer/types/types.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Cilium 3 4 package types 5 6 import ( 7 "time" 8 9 "github.com/google/uuid" 10 ) 11 12 const ( 13 // LostEventSourceUnspec indicates an event has been lost at an unknown 14 // source 15 LostEventSourceUnspec = iota 16 // LostEventSourcePerfRingBuffer indicates an event has been lost because 17 // the perf event ring buffer was not read before it was overwritten. 18 LostEventSourcePerfRingBuffer 19 // LostEventSourceEventsQueue indicates that an event has been dropped 20 // because the events queue was full. 21 LostEventSourceEventsQueue 22 // LostEventSourceHubbleRingBuffer indicates that an event was dropped 23 // because it could not be read from Hubble's ring buffer in time before 24 // being overwritten. 25 LostEventSourceHubbleRingBuffer 26 ) 27 28 // MonitorEvent is the top-level type for all events consumed by the observer 29 type MonitorEvent struct { 30 // UUID is a unique identifier for this event 31 UUID uuid.UUID 32 // Timestamp when the event was received by the consumer 33 Timestamp time.Time 34 // NodeName where the event occurred 35 NodeName string 36 // Payload is one of: AgentEvent, PerfEvent or LostEvent 37 Payload interface{} 38 } 39 40 // AgentEvent is any agent event 41 type AgentEvent struct { 42 // Type is a monitorAPI.MessageType* value 43 Type int 44 // Message is the agent message, e.g. accesslog.LogRecord, monitorAPI.AgentNotifyMessage 45 Message interface{} 46 } 47 48 // PerfEvent is a raw event obtained from a BPF perf ring buffer 49 type PerfEvent struct { 50 // Data is the raw data payload of the perf event 51 Data []byte 52 // CPU is the cpu number on which the perf event occurred 53 CPU int 54 } 55 56 // LostEvent indicates that a number of events were lost at the indicated source 57 type LostEvent struct { 58 // Source is where the events were dropped 59 Source int 60 // NumLostEvents is the number of events lost 61 NumLostEvents uint64 62 // CPU is the cpu number if for events lost in the perf ring buffer 63 CPU int 64 }