Documentation ¶
Overview ¶
Package logger provides the accesslog logging logic for all proxies
Index ¶
Constants ¶
const ( FieldType = "type" FieldVerdict = "verdict" FieldCode = "code" FieldMethod = "method" FieldURL = "url" FieldProtocol = "protocol" FieldHeader = "header" FieldFilePath = logfields.Path FieldMessage = "message" )
fields used for structured logging
const ( FieldKafkaAPIKey = "kafkaApiKey" FieldKafkaAPIVersion = "kafkaApiVersion" FieldKafkaCorrelationID = "kafkaCorrelationID" )
fields used for structured logging of Kafka messages
Variables ¶
var LogTags logTags
LogTags are optional structured tags that can be attached to log records. See NewLogRecord() and ApplyTags() for example usage.
Functions ¶
func OpenLogfile ¶ added in v1.5.0
OpenLogfile opens a file for logging
func SetMetadata ¶
func SetMetadata(md []string)
SetMetadata sets the metadata to include in each record
func SetNotifier ¶
func SetNotifier(n LogRecordNotifier)
SetNotifier sets the notifier to call for all L7 records
Types ¶
type AddressingInfo ¶
AddressingInfo is the information passed in via the Addressing() tag
type EndpointInfoRegistry ¶
type EndpointInfoRegistry interface { // FillEndpointIdentityByID resolves the labels of the specified identity // if known locally and fills in the following info member fields: // - info.Identity // - info.Labels // - info.LabelsSHA256 // Returns true if found, false if not found. FillEndpointIdentityByID(id identity.NumericIdentity, info *accesslog.EndpointInfo) bool // FillEndpointIdentityByIP resolves the labels of the endpoint with the // specified IP if known locally and fills in the following info member // fields: // - info.ID // - info.Identity // - info.Labels // - info.LabelsSHA256 // Returns true if found, false if not found. FillEndpointIdentityByIP(ip net.IP, info *accesslog.EndpointInfo) bool }
EndpointInfoRegistry provides endpoint information lookup by endpoint IP address.
type EndpointInfoSource ¶ added in v1.5.0
type EndpointInfoSource interface { GetID() uint64 GetIPv4Address() string GetIPv6Address() string GetIdentity() identity.NumericIdentity GetLabels() []string GetLabelsSHA() string HasSidecarProxy() bool // ConntrackName assumes that the caller has *not* acquired any mutexes // that may be associated with this EndpointInfoSource. It is (unfortunately) // up to the caller to know when to use this vs. ConntrackNameLocked, which // assumes that the caller has acquired any needed mutexes of the // implementation. ConntrackName() string ConntrackNameLocked() string GetIngressPolicyEnabledLocked() bool GetEgressPolicyEnabledLocked() bool ProxyID(l4 *policy.L4Filter) string GetProxyInfoByFields() (uint64, string, string, []string, string, uint64, error) }
EndpointInfoSource returns information about an endpoint being proxied. The read lock must be held when calling any method.
type EndpointUpdater ¶ added in v1.5.0
type EndpointUpdater interface { EndpointInfoSource // OnProxyPolicyUpdate is called when the proxy acknowledges that it // has applied a policy. OnProxyPolicyUpdate(policyRevision uint64) // UpdateProxyStatistics updates the Endpoint's proxy statistics to account // for a new observed flow with the given characteristics. UpdateProxyStatistics(l4Protocol string, port uint16, ingress, request bool, verdict accesslog.FlowVerdict) }
EndpointUpdater returns information about an endpoint being proxied and is called back to update the endpoint when proxy events occur. This is a subset of `Endpoint`.
type LogRecord ¶
LogRecord is a proxy log record based off accesslog.LogRecord.
func NewLogRecord ¶
func NewLogRecord(endpointInfoRegistry EndpointInfoRegistry, localEndpointInfoSource EndpointInfoSource, t accesslog.FlowType, ingress bool, tags ...LogTag) *LogRecord
NewLogRecord creates a new log record and applies optional tags
Example: record := logger.NewLogRecord(localEndpointInfoSource, flowType,
observationPoint, logger.LogTags.Timestamp(time.Now()))
type LogRecordNotifier ¶
type LogRecordNotifier interface { // NewProxyLogRecord is called for each new log record NewProxyLogRecord(l *LogRecord) error }
LogRecordNotifier is the interface to implement LogRecord notifications