Documentation
¶
Overview ¶
Package telemetry exposes engine metrics in the Prometheus format and the admin endpoints (/metrics, /healthz, /readyz).
Index ¶
- Constants
- type Metrics
- func (m *Metrics) AdapterError(kind string)
- func (m *Metrics) AdminHandler(ready func() bool) http.Handler
- func (m *Metrics) ConnectionLimitWait()
- func (m *Metrics) ConnectionOpened() (closed func())
- func (m *Metrics) EnablePolicyMetrics(max int)
- func (m *Metrics) ObserveGeoLookup(r geo.Result)
- func (m *Metrics) ObserveVerdict(v pipeline.Verdict)
- func (m *Metrics) Panicked(ctx context.Context, logger *slog.Logger, component string, v any)
- func (m *Metrics) Register(cs ...prometheus.Collector)
- func (m *Metrics) RulesReloaded(result string)
- func (m *Metrics) WatchAdmission(p *pipeline.Admission)
- func (m *Metrics) WatchRuleSets(n func() int)
- func (m *Metrics) WebSocketOpened() (closed func())
- func (m *Metrics) WebSocketViolation(code int)
Constants ¶
const ( // ErrInvalidRequest: a request the adapter can't read (a malformed // forward-auth, check, ext_proc or SPOE request, or a proxied request // with an invalid target or Host), refused without inspection. ErrInvalidRequest = "invalid_request" // ErrProtocol: a stream or connection that breaks the adapter's // protocol (ext_proc, SPOE), closed. ErrProtocol = "protocol" )
Kinds of inkwall_adapter_errors_total.
const ( // PanicExtProcStream: an ext_proc stream, ended with an error. PanicExtProcStream = "extproc_stream" // PanicSPOEConnection: a SPOE connection, closed. PanicSPOEConnection = "spoe_connection" // PanicSPOENotify: a SPOE NOTIFY frame; its connection is closed. PanicSPOENotify = "spoe_notify" // PanicWebSocket: the standalone proxy's inspection of a WebSocket's // client side; its connection is closed. PanicWebSocket = "websocket" )
Components of inkwall_panics_total: the goroutines that read a proxy's connection, where a recovered panic ends only that stream or connection.
const ( // DefaultMaxPolicies bounds inkwall_policy_requests_total's policies; // past it, requests count under policy="other". DefaultMaxPolicies = 500 )
Bounds on the series of labels whose values the engine doesn't choose.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics records verdicts. It implements pipeline.Observer. Its methods are safe on a nil *Metrics, which records nothing.
func NewMetrics ¶
NewMetrics returns metrics for one adapter (for example "proxy"), with Go runtime and process collectors registered.
func (*Metrics) AdapterError ¶ added in v0.5.0
AdapterError counts a request the adapter refused without inspecting it, by kind (ErrInvalidRequest, ErrProtocol).
func (*Metrics) AdminHandler ¶
AdminHandler serves /metrics, /healthz (the process is alive) and /readyz (the engine has loaded its rules and can serve; ready is called per probe).
func (*Metrics) ConnectionLimitWait ¶ added in v0.5.0
func (m *Metrics) ConnectionLimitWait()
ConnectionLimitWait counts a connection that waits for the limit.
func (*Metrics) ConnectionOpened ¶ added in v0.5.0
func (m *Metrics) ConnectionOpened() (closed func())
ConnectionOpened counts an open client connection; the returned func, called once it is closed, uncounts it.
func (*Metrics) EnablePolicyMetrics ¶ added in v0.5.0
EnablePolicyMetrics adds inkwall_policy_requests_total, requests by policy, for at most max distinct policies (DefaultMaxPolicies when 0 or less); past them, requests count under policy="other". Call it before the engine serves.
func (*Metrics) ObserveGeoLookup ¶
ObserveGeoLookup counts a geo policy's country lookup (policy.GeoObserver).
func (*Metrics) ObserveVerdict ¶
ObserveVerdict records one verdict.
func (*Metrics) Panicked ¶ added in v0.6.1
Panicked reports a panic recovered in a goroutine that reads a proxy's connection, by component (PanicExtProcStream...): it logs v and the stack at error level and counts it in inkwall_panics_total. Call it from the deferred function that recovered, then end that stream or connection. On a nil *Metrics it only logs.
func (*Metrics) Register ¶
func (m *Metrics) Register(cs ...prometheus.Collector)
Register adds collectors, such as the bundle agent's, to the engine's metrics.
func (*Metrics) RulesReloaded ¶ added in v0.5.0
RulesReloaded counts a reload of the rule files, by result (ok, error).
func (*Metrics) WatchAdmission ¶
WatchAdmission exports evaluation slot usage, so saturation (and with it, shed requests) is visible before it happens.
func (*Metrics) WatchRuleSets ¶ added in v0.5.0
WatchRuleSets exports the number of compiled rule sets in memory, as n reports it.
func (*Metrics) WebSocketOpened ¶ added in v0.5.0
func (m *Metrics) WebSocketOpened() (closed func())
WebSocketOpened counts an open WebSocket connection; the returned function, called when it closes (more than once is fine), uncounts it.
func (*Metrics) WebSocketViolation ¶ added in v0.5.0
WebSocketViolation counts a WebSocket message the proxy couldn't inspect or that broke the protocol, by its close code.