logstash

package
v0.0.0-...-aab34d4 Latest Latest
Warning

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

Go to latest
Published: May 27, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestStreams

func CleanupTestStreams(ts []*TestStream)

CleanupTestStreams closes all sockets and streams as well removes temporary file ressources for an array of TestStreams

func DetectVersion

func DetectVersion(logstashPath string, keptEnvVars []string) (*semver.Version, error)

DetectVersion runs "logstash --version" and tries to parse the result in order to determine which version of Logstash is being run.

Types

type BadLogstashOutputError

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

BadLogstashOutputError indicates that Logstash emitted a line that couldn't be interpreted as an event, typically because it wasn't valid JSON.

func (BadLogstashOutputError) Error

func (e BadLogstashOutputError) Error() string

Error returns a string representation of the error.

type Event

type Event map[string]interface{}

Event represents a Logstash event, i.e. basically a JSON document.

type FieldSet

type FieldSet map[string]interface{}

FieldSet contains a set of fields for a Logstash event and can be marshalled as a Logstash-compatible string that's acceptable to an add_field option for an input or filter.

func (FieldSet) IsValid

func (fs FieldSet) IsValid() error

IsValid inspects the field set and returns an error if there are any values that Logstash obviously would disapprove of (like objects in arrays).

func (FieldSet) LogstashHash

func (fs FieldSet) LogstashHash() (string, error)

LogstashHash converts a FieldSet into a Logstash-style hash that e.g. is accepted by an add_field directive in a configuration file, i.e. it has the form { "key1" => "value1" ... "keyN" => "valueN" }.

type Invocation

type Invocation struct {
	LogstashPath string
	// contains filtered or unexported fields
}

Invocation represents an invocation of Logstash, including the details of the input arguments and how to capture its log output.

func NewInvocation

func NewInvocation(logstashPath string, logstashArgs []string, logstashVersion *semver.Version, configs ...string) (*Invocation, error)

NewInvocation creates a new Invocation struct that contains all information required to start Logstash with a caller-selected set of configurations.

func (*Invocation) Args

func (inv *Invocation) Args(inputs string, outputs string) ([]string, error)

Args returns a complete slice of Logstash command arguments for the given input and output plugin configuration strings.

func (*Invocation) Release

func (inv *Invocation) Release()

Release releases any resources allocated by the struct.

type ParallelProcess

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

ParallelProcess represents the invocation and execution of a Logstash child process that emits JSON events from multiple inputs through filter to multiple outputs configuration files supplied by the caller.

func NewParallelProcess

func NewParallelProcess(inv *Invocation, testStream []*TestStream, keptEnvVars []string) (*ParallelProcess, error)

NewParallelProcess prepares for the execution of a new Logstash process but doesn't actually start it. logstashPath is the path to the Logstash executable (typically /opt/logstash/bin/logstash). The configs parameter is one or more configuration files containing Logstash filters.

func (*ParallelProcess) Release

func (p *ParallelProcess) Release()

Release frees all allocated resources connected to this process.

func (*ParallelProcess) Start

func (p *ParallelProcess) Start() error

Start starts a Logstash child process with the previously supplied configuration.

func (*ParallelProcess) Wait

func (p *ParallelProcess) Wait() (*ParallelResult, error)

Wait blocks until the started Logstash process terminates and returns the result of the execution.

type ParallelResult

type ParallelResult struct {
	// Success indicates whether the execution was successful,
	// i.e. whether the Logstash process terminated with a zero
	// exit status.
	Success bool

	// Events contains a slice of the events emitted from
	// Logstash.
	Events [][]Event

	// Log contains the contents of the Logstash log file.
	Log string

	// Output contains stdout and stderr output (if any) of
	// the Logstash process. If the process fails during
	// initialization clues can probably be found here.
	Output string
}

ParallelResult contains the results of a parallel Logstash execution, where multiple test cases are run in parallel via unix domain sockets.

type Process

type Process struct {
	// Input will be connected to the stdin stream of the started
	// Logstash process. Make sure to close it when all data has
	// been written so that the process will terminate.
	Input io.WriteCloser
	// contains filtered or unexported fields
}

Process represents the invocation and execution of a Logstash child process that emits JSON events from the input and filter configuration files supplied by the caller.

func NewProcess

func NewProcess(inv *Invocation, inputCodec string, fields FieldSet, keptEnvVars []string) (*Process, error)

NewProcess prepares for the execution of a new Logstash process but doesn't actually start it. logstashPath is the path to the Logstash executable (typically /opt/logstash/bin/logstash), inputCodec is the desired codec for the stdin input and inputType the value of the "type" field for ingested events. The configs parameter is one or more configuration files containing Logstash filters.

func (*Process) Release

func (p *Process) Release()

Release frees all allocated resources connected to this process.

func (*Process) Start

func (p *Process) Start() error

Start starts a Logstash child process with the previously supplied configuration.

func (*Process) Wait

func (p *Process) Wait() (*Result, error)

Wait blocks until the started Logstash process terminates and returns the result of the execution.

type Result

type Result struct {
	// Success indicates whether the execution was successful,
	// i.e. whether the Logstash process terminated with a zero
	// exit status.
	Success bool

	// Events contains a slice of the events emitted from
	// Logstash.
	Events []Event

	// Log contains the contents of the Logstash log file.
	Log string

	// Output contains stdout and stderr output (if any) of
	// the Logstash process. If the process fails during
	// initialization clues can probably be found here.
	Output string
}

Result contains the result of a Logstash execution.

type TestStream

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

TestStream contains the input and output streams for one test case

func NewTestStream

func NewTestStream(inputCodec string, fields FieldSet, timeout time.Duration) (*TestStream, error)

NewTestStream creates a TestStream, inputCodec is the desired codec for the stdin input and inputType the value of the "type" field for ingested events. The timeout defines, how long to wait in Write for the receiver to become available.

func (*TestStream) Cleanup

func (ts *TestStream) Cleanup()

Cleanup closes and removes all temporary resources for a TestStream

func (*TestStream) Close

func (ts *TestStream) Close() error

Close closes the sender of the TestStream

func (*TestStream) Write

func (ts *TestStream) Write(p []byte) (n int, err error)

Write writes to the sender of the TestStream

Jump to

Keyboard shortcuts

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