http

package module
v0.0.0-...-415ffb8 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2017 License: Apache-2.0 Imports: 23 Imported by: 0

README

beats-http-output

This is an http(s) output for Elastic beats. It allows for HTTP POSTs of collected events to an API. So far I have added the following features:

  • Ability to specify HTTP headers
  • Ability to microbatch events into a single POST. You can specify:
    • Batch size
    • Minimum time between POSTS
    • Maximum time between POSTS

Usage

To use this output you have to clone the Elastic beats project: https://github.com/elastic/beats/tree/v5.5.1 and modify main.go by adding one line importing this project.

package main

import (
	"os"

	_ "github.com/brianconcannon/beats-http-output"

    "github.com/elastic/beats/libbeat/beat"
	"github.com/elastic/beats/winlogbeat/beater"
)

var Name = "winlogbeat"

func main() {
	if err := beat.Run(Name, "", beater.New); err != nil {
		os.Exit(1)
	}
}

Then configure the http output plugin in winlogbeat.yml:

output:
  http:
    hosts: ["https://www.example.com:443/foo"]
    headers:
        Content-Type: application/json
        X-API-Key: abcdefghijklmnop...

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotConnected indicates failure due to client having no valid connection
	ErrNotConnected = errors.New("not connected")

	// ErrJSONEncodeFailed indicates encoding failures
	ErrJSONEncodeFailed = errors.New("json encode failed")
)

Functions

func New

func New(beatName string, cfg *common.Config, _ int) (outputs.Outputer, error)

Types

type Client

type Client struct {
	Connection
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	s ClientSettings,
) (*Client, error)

func (*Client) Clone

func (client *Client) Clone() *Client

func (*Client) FlushBuffer

func (client *Client) FlushBuffer() error

func (*Client) PublishEvent

func (client *Client) PublishEvent(data outputs.Data) error

func (*Client) PublishEvents

func (client *Client) PublishEvents(
	data []outputs.Data,
) ([]outputs.Data, error)

PublishEvents posts all events to the http endpoint. On error a slice with all events not published will be returned.

func (*Client) ResetTimer

func (client *Client) ResetTimer()

type ClientSettings

type ClientSettings struct {
	URL                string
	Proxy              *url.URL
	TLS                *transport.TLSConfig
	Username, Password string
	Parameters         map[string]string
	Headers            map[string]string
	Index              outil.Selector
	Pipeline           *outil.Selector
	Timeout            time.Duration
	CompressionLevel   int
	BufferMinInterval  time.Duration
	BufferMaxInterval  time.Duration
	BufferCount        int
}

type Connection

type Connection struct {
	URL      string
	Username string
	Password string
	Headers  map[string]string
	// contains filtered or unexported fields
}

func (*Connection) Close

func (conn *Connection) Close() error

func (*Connection) Connect

func (conn *Connection) Connect(timeout time.Duration) error

func (*Connection) IsConnected

func (conn *Connection) IsConnected() bool

Jump to

Keyboard shortcuts

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