Categorygithub.com/kentik/libkflow
modulepackage
2.4.0+incompatible
Repository: https://github.com/kentik/libkflow.git
Documentation: pkg.go.dev

# README

libkflow - library for sending kflow

libkflow is a library for generating and sending kflow records to Kentik written in Go and also providing a simple C API.

Go Usage

Create a libkflow Config and pass it to one of the NewSenderWith* methods, along with the appropriate device identifier and an error channel which may be polled for asynchronous errors.

errors := make(chan error, 100)
config := libkflow.NewConfig("email", "token", "program", "1.0.0")
s, err := libkflow.NewSenderWithDeviceID(0, errors, config)
s.Send(&flow.Flow{
	Ipv4SrcAddr: src,
	Ipv4DstAddr: dst,
})

C Usage

demo.c provides an example of correct API usage and will send one flow record to the test server which is expected to be running and listening on 127.0.0.1:8999.

Mock Server

A mock server that accepts API, flow, and metrics requests is available for testing purposes:

go install github.com/kentik/libkflow/cmd/server && bin/server

A variety of command line parameters are available, by default it will listen on 127.0.0.1:8999 and accept some default values for authentication and device identification. A full demonstration program written in Go is available:

main.go

Build

Building libkflow requires GNU make and the Go toolchain. Set GOPATH to the directory containing this file and invoke make:

$ export PATH=$PWD
$ make

The default make target will build libkflow.a and create a distribution libkflow-$VERSION-$TARGET.tar.gz file containing the compiled library, test server binary, demo.c, and kflow.h.

All built artifacts will be placed in $CURDIR/out/$TARGET where $CURDIR is the current working directory and $TARGET is $GOOS-$GOARCH, for example linux-amd64.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

NewConfig returns a new Config given an API access email and token, and the name and version of the program using libkflow.
NewSenderFromDevice returns a Sender for an existing Device.
NewSenderFromDeviceWithErrors returns a Sender and an error channel for an existing Device.
NewSenderWithDeviceID creates a new flow Sender given a device ID, error channel, and Config.
NewSenderWithDeviceIF creates a new flow Sender given a device interface name, error channel, and Config.
NewSenderWithDeviceIP creates a new flow Sender given a device IP address, error channel, and Config.
NewSenderWithDeviceName creates a new flow Sender given a device name address, error channel, and Config.
NewSenderWithDeviceNameWithErrors creates a new flow Sender given a device name address and Config.
NewSenderWithNewDevice creates a new device given device creation parameters, and then creates a new flow Sender with that device, the error channel, and the Config.
NewSenderWithNewDeviceWithErrors creates a new device and returns a new flow Sender and an error channel which will report errors generated from the Sender.
NewSenderWithNewSiteAndDevice creates a new device and site then returns a flow Sender for that newly created device.
NewSenderWithNewSiteAndDeviceWithErrors is the same as NewSenderWithNewSiteAndDeviceWithErrors except rather than passing in a channel to receive errors, a channel is returned by the function.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
Version of libkflow.

# Structs

Capture describes the packet capture settings.
Config describes the libkflow configuration.
A Sender aggregates and transmits flow information to Kentik.

# Interfaces

LeveledLogger interface implements the basic methods that a logger library needs.
Logger interface allows to use other loggers than standard log.Logger.