export

package
v0.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 55 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package export sends the engines' security events to SIEMs and log pipelines, from every operator replica, without the control plane (design 0010): each replica exports the events of the engines connected to it, from one bounded buffer with a cursor per sink, as OTLP logs (gRPC or HTTP) or JSON over HTTP.

Index

Constants

View Source
const (
	DefaultBufferBytes  = 32 << 20
	DefaultDiskBytes    = 512 << 20
	DefaultFlushTimeout = 15 * time.Second
)

Defaults of the Exporter (design 0010 §2.4).

View Source
const (
	// SchemaVersion is the schema's version: the scope version in OTLP.
	SchemaVersion = "1"
	// SchemaName is the "schema" of every JSON event.
	SchemaName = "inkwall.dev/security-event/v" + SchemaVersion
)

The exported event (design 0010 §5): the SecurityEvent, with what the operator adds (the cluster, the time it received the event). Field names are stable within a schema version; the golden tests pin them.

View Source
const (
	DropBufferFull = "buffer_full"
	DropRejected   = "rejected"
	DropTooLarge   = "too_large"
)

Why events were never delivered: the reason label of the dropped metric.

View Source
const (
	StateConfigInvalid  = enginereport.SinkConfigInvalid
	StateAddressRefused = enginereport.SinkAddressRefused
	StateFailing        = enginereport.SinkFailing
	StateDropping       = enginereport.SinkDropping
	StateExporting      = enginereport.SinkExporting
)

The state classes of a sink, in the order of precedence of the EventsExported condition: the first that applies wins.

View Source
const DefaultStatusWindow = 5 * time.Minute

DefaultStatusWindow is how long a sink fails without a success to be Failing, and how recently one that dropped for a full buffer is Dropping (design 0010 §8).

Variables

This section is empty.

Functions

This section is empty.

Types

type AddressRefusedError

type AddressRefusedError struct {
	// Class is loopback, unspecified, link-local or metadata.
	Class string
}

AddressRefusedError is a connection refused by the dialer's guard. Its message names the address class, never the address.

func (*AddressRefusedError) Error

func (e *AddressRefusedError) Error() string

type Exporter

type Exporter struct {
	// Client reads the InkwallConfig and the operator's Secrets (cached).
	Client client.Reader
	// APIReader reads the kube-system Namespace, whose UID is the cluster's
	// ID, which the manager doesn't cache.
	APIReader client.Reader
	// Namespace is the operator's: the Secrets the sinks name are there.
	Namespace string
	// Dir holds the buffer on disk ("": in memory only); MemoryBytes and
	// DiskBytes bound it (defaults DefaultBufferBytes, DefaultDiskBytes).
	Dir                    string
	MemoryBytes, DiskBytes int64
	// FlushTimeout bounds the flush on Stop (default DefaultFlushTimeout).
	FlushTimeout time.Duration
	// Poll is how often the configuration and its Secrets are read again
	// (default 2 s).
	Poll time.Duration
	// HasPolicy reports whether the bundle this replica serves has a policy
	// (distribution.Store.HasPolicy): an event's policy counts only then.
	HasPolicy func(string) bool
	// StatusWindow: a sink failing this long without a success is
	// Failing; one that dropped for a full buffer within it, Dropping
	// (default DefaultStatusWindow; the e2e test shortens it).
	StatusWindow time.Duration
	Metrics      Metrics
	Log          logr.Logger
	// contains filtered or unexported fields
}

Exporter exports the security events this replica receives. It isn't a manager runnable: the distribution server starts it, and stops it once its gRPC server has stopped, so no Add comes after the flush.

func (*Exporter) Add

func (e *Exporter) Add(b *eventsv1.EventBatch)

Add takes a batch from an engine (distribution.Server.Events), read only. It never blocks: it appends the batch under a mutex and returns, and a full buffer drops the oldest.

func (*Exporter) Report

func (e *Exporter) Report() []enginereport.Sink

Report is Status as the replica's engine report carries it, for the leader's EventsExported condition and inkwallctl status.

func (*Exporter) Start

func (e *Exporter) Start() error

Start opens the buffer (loading what a previous run left on disk) and starts the export. A directory that can't be used is replaced by memory.

func (*Exporter) Status

func (e *Exporter) Status() []SinkStatus

Status is each sink's state on this replica, sorted by name; none without sinks.

func (*Exporter) Stop

func (e *Exporter) Stop()

Stop flushes: each sink sends what it holds at once, for up to FlushTimeout; then the senders stop and the buffer writes what is left to disk (lost with the pod, kept across a container restart). Call it once no Add can come.

type Metrics

type Metrics interface {
	Exported(sink string, n int)
	Dropped(sink, reason string, n int)
	Failed(sink, kind string)
	Duration(sink string, d time.Duration)
	Succeeded(sink string, at time.Time)
	Pending(sink string, n uint64)
	BufferBytes(n int64)
	Forget(sink string)
	// Start makes a new sink's series, at 0.
	Start(sink string)
}

Metrics receives what the exporter counts (operator metrics); nil counts nothing.

type PrometheusMetrics

type PrometheusMetrics struct{}

PrometheusMetrics reports to the operator's metrics registry.

func (PrometheusMetrics) BufferBytes

func (PrometheusMetrics) BufferBytes(n int64)

BufferBytes sets the export buffer's size.

func (PrometheusMetrics) Dropped

func (PrometheusMetrics) Dropped(sink, reason string, n int)

Dropped counts the events a sink never got, by reason.

func (PrometheusMetrics) Duration

func (PrometheusMetrics) Duration(sink string, d time.Duration)

Duration observes a request's time.

func (PrometheusMetrics) Exported

func (PrometheusMetrics) Exported(sink string, n int)

Exported counts the events a sink accepted.

func (PrometheusMetrics) Failed

func (PrometheusMetrics) Failed(sink, kind string)

Failed counts a failed request, by kind.

func (PrometheusMetrics) Forget

func (PrometheusMetrics) Forget(sink string)

Forget removes a removed sink's series.

func (PrometheusMetrics) Pending

func (PrometheusMetrics) Pending(sink string, n uint64)

Pending sets the events the sink hasn't had accepted.

func (PrometheusMetrics) Start

func (PrometheusMetrics) Start(sink string)

Start makes a sink's series, at 0.

func (PrometheusMetrics) Succeeded

func (PrometheusMetrics) Succeeded(sink string, at time.Time)

Succeeded sets when the sink last accepted a request.

type SinkStatus

type SinkStatus struct {
	Name string `json:"name"`
	// State is one of the State constants.
	State string `json:"state"`
	// Message says why, for every state but Exporting: the error class,
	// never a Secret or more than a short, escaped part of a response.
	Message string `json:"message,omitempty"`
	// Pending counts the events the sink hasn't had answered.
	Pending uint64 `json:"pending"`
	// Plaintext: the sink's endpoint is http:// or grpc://.
	Plaintext   bool      `json:"plaintext,omitempty"`
	LastSuccess time.Time `json:"lastSuccess,omitzero"`
}

SinkStatus is a sink's state on this replica.

Jump to

Keyboard shortcuts

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