Documentation
¶
Overview ¶
Package receiver provides various skogul Receivers that accept data and execute a handler. They are the "inbound" API of Skogul.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Auto skogul.ModuleMap
Auto maps names to Receivers to allow auto configuration
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { File string `doc:"Path to the file to read from once."` Handler skogul.HandlerRef `doc:"Handler used to parse, transform and send data."` // contains filtered or unexported fields }
File reads from a FILE, a single JSON object per line, and exits at EOF.
type HTTP ¶
type HTTP struct { Address string `doc:"Address to listen to." example:"[::1]:80 [2001:db8::1]:443"` Handlers map[string]*skogul.HandlerRef `doc:"Paths to handlers. Need at least one." example:"{\"/\": \"someHandler\" }"` Auth map[string]*HTTPAuth `doc:"A map corresponding to Handlers; specifying authentication for the given path, if required."` Certfile string `doc:"Path to certificate file for TLS. If left blank, un-encrypted HTTP is used."` Keyfile string `doc:"Path to key file for TLS."` }
HTTP accepts HTTP connections on the Address specified, and requires at least one handler to be set up, using Handle. This is done implicitly if the HTTP receiver is created using New()
Example ¶
HTTP can have different skogul.Handler's for different paths, with potentially different behaviors.
package main import ( "github.com/telenornms/skogul" "github.com/telenornms/skogul/parser" "github.com/telenornms/skogul/receiver" "github.com/telenornms/skogul/sender" "github.com/telenornms/skogul/transformer" ) func main() { h := receiver.HTTP{Address: "localhost:8080"} template := skogul.Handler{Transformers: []skogul.Transformer{transformer.Templater{}}, Sender: &sender.Debug{}} template.SetParser(parser.JSON{}) noTemplate := skogul.Handler{Sender: &sender.Debug{}} noTemplate.SetParser(parser.JSON{}) h.Handlers = map[string]*skogul.HandlerRef{ "/template": {H: &template}, "/notemplate": {H: &noTemplate}, } h.Start() }
Output:
type HTTPAuth ¶ added in v0.3.0
type HTTPAuth struct { Username string `doc:"Username for basic authentication. No authentication is required if left blank."` Password string `doc:"Password for basic authentication."` }
HTTPAuth contains ways to authenticate a HTTP request, e.g. Username/Password for Basic Auth.
type LineFile ¶
type LineFile struct { File string `doc:"Path to the fifo or file from which to read from repeatedly."` Handler skogul.HandlerRef `doc:"Handler used to parse and transform and send data."` Delay skogul.Duration `doc:"Delay before re-opening the file, if any."` }
LineFile will keep reading File over and over again, assuming one collection per line. Best suited for pointing at a FIFO, which will allow you to 'cat' stuff to Skogul.
type LogrusLog ¶ added in v0.3.0
type LogrusLog struct { Loglevel string Handler skogul.HandlerRef }
LogrusLog configures the logrus log receiver
type LogrusSkogulHook ¶ added in v0.3.0
LogrusSkogulHook is a logrus.Hook made for skogul
func (*LogrusSkogulHook) Fire ¶ added in v0.3.0
func (hook *LogrusSkogulHook) Fire(entry *logrus.Entry) error
Fire implements the logrus.Hook interface and handles each log entry
func (*LogrusSkogulHook) Levels ¶ added in v0.3.0
func (hook *LogrusSkogulHook) Levels() []logrus.Level
Levels returns the log levels the hook should care about
type MQTT ¶
type MQTT struct { Broker string `doc:"Address of broker to connect to." example:"[::1]:8888"` Topics []string `doc:"List of topics to subscribe to"` Handler *skogul.HandlerRef `doc:"Handler used to parse, transform and send data."` Password string `doc:"Username for authenticating to the broker."` Username string `doc:"Password for authenticating."` ClientID string `doc:"Custom client id to use (default: random)"` // contains filtered or unexported fields }
MQTT connects to a MQTT broker and listens for messages on a topic.
type Stdin ¶
type Stdin struct { Handler skogul.HandlerRef `doc:"Handler used to parse, transform and send data."` // contains filtered or unexported fields }
Stdin reads from /dev/stdin
type TCPLine ¶
type TCPLine struct { Address string `doc:"Address and port to listen to." example:"[::1]:3306"` Handler skogul.HandlerRef `doc:"Handler used to parse, transform and send data."` }
TCPLine listens on a IP:TCP port specified in the Address string and accepts one container per line to be sent to the parser.
Example usage, assuming JSON parser:
$ cat payloads/simple.json | jq -c . | nc '::1' '1234'
Since this is not possible to secure, it should be avoided where possible and placed as close to the data source. A good use of this model is to use a TCPLine receiver on the same box that needs to write to it, combined with skogul.senders.HTTP to forward over a more sensible channel.
type Tester ¶
type Tester struct { Metrics int64 `doc:"Number of metrics in each container"` Values int64 `doc:"Number of unique values for each metric"` Threads int `doc:"Threads to spawn"` Delay skogul.Duration `doc:"Sleep time between each metric is generated, if any."` Handler skogul.HandlerRef `doc:"Reference to a handler where the data is sent"` }
Tester synthesise dummy data.
type UDP ¶
type UDP struct { Address string `doc:"Address and port to listen to." example:"[::1]:3306"` Handler skogul.HandlerRef `doc:"Handler used to parse, transform and send data."` }
UDP contains the configuration for the receiver