exporter

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: Apache-2.0 Imports: 14 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateIPFIXMsg added in v0.8.0

func CreateIPFIXMsg(set entities.Set, obsDomainID uint32, seqNumber uint32, exportTime time.Time) ([]byte, error)

func WriteIPFIXMsgToBuffer added in v0.12.0

func WriteIPFIXMsgToBuffer(set entities.Set, obsDomainID uint32, seqNumber uint32, exportTime time.Time, buf *bytes.Buffer) (int, error)

WriteIPFIXMsgToBuffer serializes the set as an IPFIX message and writes it to the provided buffer. It returns the message length and an error if applicable.

Types

type BufferedIPFIXExporter added in v0.13.0

type BufferedIPFIXExporter struct {
	// contains filtered or unexported fields
}

BufferedIPFIXExporter wraps an ExportingProcess instance and supports buffering data records before sending them. BufferedIPFIXExporter is not safe for usage by multiple goroutines. There should be a single BufferedIPFIXExporter created for a given ExportingProcess. While the BufferedIPFIXExporter supports sending JSON records, in that case it mostly acts as a passthrough to the underlying ExportingProcess (no actual buffering).

func NewBufferedIPFIXExporter added in v0.13.0

func NewBufferedIPFIXExporter(ep *ExportingProcess) *BufferedIPFIXExporter

NewBufferedIPFIXExporter creates a BufferedIPFIXExporter .

func (*BufferedIPFIXExporter) AddRecord added in v0.13.0

func (e *BufferedIPFIXExporter) AddRecord(record entities.Record) error

AddRecord adds a record to be sent to the destination collector. If it is a template record, then it will be sent to the collector right away. If it is a data record, it will be added to the buffer. If adding the record to the buffer would cause the buffer length to exceed the max message size, the buffer is flushed first. Note that because data records are serialized to the buffer immediately, it is safe for the provided record to be mutated as soon as this function returns.

func (*BufferedIPFIXExporter) Flush added in v0.13.0

func (e *BufferedIPFIXExporter) Flush() error

Flush sends all buffered data records immediately.

type ExporterInput added in v0.4.0

type ExporterInput struct {
	// CollectorAddress needs to be provided in hostIP:port format.
	CollectorAddress string
	// CollectorProtocol needs to be provided in lower case format.
	// We support "tcp" and "udp" protocols.
	CollectorProtocol   string
	ObservationDomainID uint32
	TempRefTimeout      uint32
	// TLSClientConfig is set to use an encrypted connection to the collector.
	TLSClientConfig *ExporterTLSClientConfig
	IsIPv6          bool
	SendJSONRecord  bool
	// JSONBufferLen is recommended for sending json records. If not given a
	// valid value, we use a default of 5000B
	JSONBufferLen int
	// MaxMsgSize can be used to provide a custom maximum IPFIX message
	// size. If it is omitted, we will use an appropriate default based on
	// the configured protocol. For UDP, we want to avoid fragmentation, so
	// the MaxMsgSize should be set by taking into account the PMTU and
	// header sizes. The recommended approach is to keep MaxMsgSize unset
	// and provide the correct PMTU value.
	MaxMsgSize int
	// PathMTU is used to calculate the maximum message size when the
	// protocol is UDP. It is ignored for TCP. If both MaxMsgSize and
	// PathMTU are set, and MaxMsgSize is incompatible with the provided
	// PathMTU, exporter initialization will fail.
	PathMTU           int
	CheckConnInterval time.Duration
}

type ExporterTLSClientConfig added in v0.5.14

type ExporterTLSClientConfig struct {
	// ServerName is passed to the server for SNI and is used in the client to check server
	// certificates against. If ServerName is empty, the hostname used to contact the
	// server is used.
	ServerName string
	// CAData holds PEM-encoded bytes for trusted root certificates for server.
	CAData []byte
	// CertData holds PEM-encoded bytes.
	CertData []byte
	// KeyData holds PEM-encoded bytes.
	KeyData []byte
}

type ExportingProcess

type ExportingProcess struct {
	// contains filtered or unexported fields
}
  1. Tested one exportingProcess process per exporter. Can support multiple collector scenario by creating different instances of exporting process. Need to be tested
  2. Only one observation point per observation domain is supported, so observation point ID not defined.
  3. Supports only TCP and UDP; one session at a time. SCTP is not supported.
  4. UDP needs to send PMTU size packets as per RFC7011. In order to guarantee this, maxMsgSize should be set correctly. maxMsgSize is the maximum payload (IPFIX message) size, not the maximum packet size. If maxMsgSize is not set correctly, the message may be fragmented.

func InitExportingProcess

func InitExportingProcess(input ExporterInput) (*ExportingProcess, error)

InitExportingProcess takes in collector address(net.Addr format), obsID(observation ID) and tempRefTimeout(template refresh timeout). tempRefTimeout is applicable only for collectors listening over UDP; unit is seconds. For TCP, you can pass any value and it will be ignored. For UDP, if 0 is passed, 600s is used as the default.

func (*ExportingProcess) CloseConnToCollector

func (ep *ExportingProcess) CloseConnToCollector()

CloseConnToCollector closes the connection to the collector. It can safely be closed more than once, and subsequent calls will be no-ops.

func (*ExportingProcess) GetMsgSizeLimit added in v0.4.2

func (ep *ExportingProcess) GetMsgSizeLimit() int

GetMsgSizeLimit returns the maximum IPFIX message size that this exporter is allowed to write to the connection. If the exporter is configured to send marshalled JSON records instead, this function will return 0.

func (*ExportingProcess) NewTemplateID

func (ep *ExportingProcess) NewTemplateID() uint16

NewTemplateID is called to get ID when creating new template record.

func (*ExportingProcess) SendDataRecords added in v0.12.0

func (ep *ExportingProcess) SendDataRecords(templateID uint16, records []entities.Record, buf *bytes.Buffer) (int, int, error)

SendDataRecords is a specialized version of SendSet which can send a list of data records more efficiently. All the data records must be for the same template ID. This function performs fewer sanity checks on the data records, compared to SendSet. This function can also take a reusable buffer as a parameter to avoid repeated memory allocations. You can use nil as the buffer if you want this function to be responsible for allocation. SendDataRecords returns the number of records successfully sent, the total number of bytes sent, and an error if applicable.

func (*ExportingProcess) SendSet added in v0.4.0

func (ep *ExportingProcess) SendSet(set entities.Set) (int, error)

SendSet sends the provided set and returns the number of bytes written and an error if applicable.

Jump to

Keyboard shortcuts

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