outputelastic

package
v0.0.0-...-5039c01 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 12 Imported by: 3

README

gogstash output elastic

Synopsis

output:
  - type: elastic
    # (required)
    # elastic API entrypoints
    url: ["http://127.0.0.1:9200"]

    # (required)
    # index name to log
    index: "gogstash-index-test"

    # (deprecated)
    # type name to log
    document_type: "testtype"

    # (optional) default: ""
    # id to log, used if you want to control id format
    document_id: "%{fieldstring}"

    # (optional) default: ""
    # username to use in basic auth
    username: ""

    # (optional) default: ""
    # password to use in basic auth
    password: ""

    # (optional) default: false
    # find all nodes of your cluster, https://github.com/olivere/elastic/wiki/Sniffing
    sniff: true

    # (optional) default: false
    # uses the simpleclient connection type instead of the normal client, helpful in cases you get error messages even when the client can connect
    simple_client: true

    # (optional) default: 1000
    # BulkActions specifies when to flush based on the number of actions
    # currently added. Defaults to 1000 and can be set to -1 to be disabled.
    bulk_actions: 1000

    # (optional) default: 5242880 (5MB)
    # BulkSize specifies when to flush based on the size (in bytes) of the actions
    # currently added. Defaults to 5 MB and can be set to -1 to be disabled.
    bulk_size: 5242880

    # (optional) default: 30000000000 (30s)
    # BulkFlushInterval specifies when to flush at the end of the given interval.
    # Defaults to 30 seconds. If you want the bulk processor to
    # operate completely asynchronously, set both BulkActions and BulkSize to
    # -1 and set the FlushInterval to a meaningful interval.
    bulk_flush_interval: 30000000000

    # (optional) default: "10s"
    # ExponentialBackoffInitialTimeout used to set the first/minimal interval in elastic.ExponentialBackoff
    exponential_backoff_initial_timeout: "10s"

    # (optional) default: "5m"
    # ExponentialBackoffMaxTimeout used to set the maximum wait interval in elastic.ExponentialBackoff
    exponential_backoff_max_timeout: "5m"

    # (optional) default: "true"
    # SSLCertValidation Option to validate the server's certificate. Disabling this severely compromises security.
    # For more information on disabling certificate verification please read https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
    ssl_certificate_validation: false

Documentation

Index

Constants

View Source
const ModuleName = "elastic"

ModuleName is the name used in config file

Variables

View Source
var (
	ErrorCreateClientFailed1 = errutil.NewFactory("create elastic client failed: %q")
)

errors

Functions

func InitHandler

func InitHandler(
	ctx context.Context,
	raw config.ConfigRaw,
	control config.Control,
) (config.TypeOutputConfig, error)

InitHandler initialize the output plugin

Types

type OutputConfig

type OutputConfig struct {
	config.OutputConfig
	URL []string `json:"url"` // elastic API entrypoints

	Index           string `json:"index"`             // index name to log
	DocumentType    string `json:"document_type"`     // type name to log
	DocumentID      string `json:"document_id"`       // id to log, used if you want to control id format
	RetryOnConflict int    `json:"retry_on_conflict"` // the number of times Elasticsearch should internally retry an update/upserted document
	Username        string `json:"username"`          // basic auth username to Elasticsearch
	Password        string `json:"password"`          // basic auth password to Elasticsearch
	SimpleClient    bool   `json:"simple_client"`     // if set uses simpleclient instead of newclient, disables some functionality

	Sniff bool `json:"sniff"` // find all nodes of your cluster, https://github.com/olivere/elastic/wiki/Sniffing

	// BulkActions specifies when to flush based on the number of actions
	// currently added. Defaults to 1000 and can be set to -1 to be disabled.
	BulkActions int `json:"bulk_actions,omitempty"`

	// BulkSize specifies when to flush based on the size (in bytes) of the actions
	// currently added. Defaults to 5 MB and can be set to -1 to be disabled.
	BulkSize int `json:"bulk_size,omitempty"`

	// BulkFlushInterval specifies when to flush at the end of the given interval.
	// Defaults to 30 seconds. If you want the bulk processor to
	// operate completely asynchronously, set both BulkActions and BulkSize to
	// -1 and set the FlushInterval to a meaningful interval.
	BulkFlushInterval time.Duration `json:"bulk_flush_interval"`

	// ExponentialBackoffInitialTimeout used to set the first/minimal interval in elastic.ExponentialBackoff
	// Defaults to 10s
	ExponentialBackoffInitialTimeout string `json:"exponential_backoff_initial_timeout,omitempty"`

	// ExponentialBackoffMaxTimeout used to set the maximum wait interval in elastic.ExponentialBackoff
	// Defaults to 5m
	ExponentialBackoffMaxTimeout string `json:"exponential_backoff_max_timeout,omitempty"`

	// SSLCertValidation Option to validate the server's certificate. Disabling this severely compromises security.
	// For more information on disabling certificate verification please read https://www.cs.utexas.edu/~shmat/shmat_ccs12.pdf
	SSLCertValidation bool `json:"ssl_certificate_validation,omitempty"`
	// contains filtered or unexported fields
}

OutputConfig holds the configuration json fields and internal objects

func DefaultOutputConfig

func DefaultOutputConfig() OutputConfig

DefaultOutputConfig returns an OutputConfig struct with default values

func (*OutputConfig) BulkAfter

func (t *OutputConfig) BulkAfter(executionID int64, requests []elastic.BulkableRequest, response *elastic.BulkResponse, err error)

BulkAfter execute after a commit to Elasticsearch

func (*OutputConfig) Output

func (t *OutputConfig) Output(ctx context.Context, event logevent.LogEvent) (err error)

Output event

Jump to

Keyboard shortcuts

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