postgres

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxDataSizePostgres is the maximum size of SQL query data captured
	MaxDataSizePostgres = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	*config.BaseConfig
	PostgresPath string // Path to PostgreSQL binary
	FuncName     string // Function name to hook (default: exec_simple_query)
	Offset       uint64 // Function offset (optional, auto-discovered if not set)
}

Config extends BaseConfig with PostgreSQL-specific configuration

func NewConfig

func NewConfig() *Config

NewConfig creates a new PostgreSQL probe configuration

func (*Config) GetFuncName

func (c *Config) GetFuncName() string

GetFuncName returns the function name to hook

func (*Config) GetOffset

func (c *Config) GetOffset() uint64

GetOffset returns the function offset

func (*Config) GetPostgresPath

func (c *Config) GetPostgresPath() string

GetPostgresPath returns the PostgreSQL binary path

func (*Config) SetFuncName

func (c *Config) SetFuncName(name string)

SetFuncName sets the function name to hook

func (*Config) SetOffset

func (c *Config) SetOffset(offset uint64)

SetOffset sets the function offset

func (*Config) SetPostgresPath

func (c *Config) SetPostgresPath(path string)

SetPostgresPath sets the PostgreSQL binary path

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the PostgreSQL configuration

type Event

type Event struct {
	Pid       uint64                     `json:"pid"`
	Timestamp uint64                     `json:"timestamp"`
	Query     [MaxDataSizePostgres]uint8 `json:"query"`
	Comm      [16]uint8                  `json:"comm"`
}

Event represents a PostgreSQL query event from eBPF This structure matches the C struct in postgres_kern.c:

struct postgres_event_t {
    u64 pid;
    u64 timestamp;
    char Query[MAX_DATA_SIZE];
    char Comm[TASK_COMM_LEN];
};

func (*Event) Clone

func (e *Event) Clone() domain.Event

Clone creates a deep copy of the event

func (*Event) DecodeFromBytes

func (e *Event) DecodeFromBytes(data []byte) error

DecodeFromBytes decodes the event from raw bytes

func (*Event) GetComm

func (e *Event) GetComm() string

GetComm returns the command name

func (*Event) GetPid

func (e *Event) GetPid() uint64

GetPid returns the process ID

func (*Event) GetQuery

func (e *Event) GetQuery() string

GetQuery returns the SQL query string

func (*Event) GetTimestamp

func (e *Event) GetTimestamp() uint64

GetTimestamp returns the event timestamp

func (*Event) IsTruncated

func (e *Event) IsTruncated() bool

IsTruncated checks if the query was truncated

func (*Event) PerfMonoNs

func (e *Event) PerfMonoNs() uint64

PerfMonoNs implements domain.MonoNsEvent (ebpf timestamp / bpf_ktime_get_ns).

func (*Event) String

func (e *Event) String() string

String returns a human-readable string representation of the event

func (*Event) StringHex

func (e *Event) StringHex() string

StringHex returns a hexadecimal string representation of the event

func (*Event) Type

func (e *Event) Type() domain.EventType

Type returns the event type identifier

func (*Event) UUID

func (e *Event) UUID() string

UUID returns a unique identifier for this event

func (*Event) Validate

func (e *Event) Validate() error

Validate validates the event data

type Probe

type Probe struct {
	*base.BaseProbe
	// contains filtered or unexported fields
}

Probe implements PostgreSQL query monitoring using uprobe

func NewProbe

func NewProbe() *Probe

NewProbe creates a new PostgreSQL probe instance

func (*Probe) Close

func (p *Probe) Close() error

Close closes the PostgreSQL probe and releases resources

func (*Probe) Initialize

func (p *Probe) Initialize(ctx context.Context, cfg domain.Configuration) error

Initialize initializes the PostgreSQL probe with the provided configuration

func (*Probe) Start

func (p *Probe) Start(ctx context.Context) error

Start starts the PostgreSQL probe

func (*Probe) Stop

func (p *Probe) Stop(ctx context.Context) error

Stop stops the PostgreSQL probe

Jump to

Keyboard shortcuts

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