socket

package
v0.81.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: BSD-3-Clause Imports: 13 Imported by: 0

README

Socket plugin

It sends events to a socket endpoint. Supports TCP, UDP, and Unix socket protocols.

Events are sent in batches serialized as newline-delimited JSON by default, compatible with the socket input plugin. The delimiter used to separate messages is configurable and can be changed in the plugin configuration (default: \n). If a network error occurs, the batch will be retried according to the backoff settings.

Supports dead queue.

Examples

TCP:

pipelines:
  example_pipeline:
    ...
    output:
      type: socket
      network: tcp
      address: ':6666'
      delimiter: '\t'
    ...

TLS:

pipelines:
  example_pipeline:
    ...
    output:
      type: socket
      network: tcp
      address: ':6666'
      delimiter: '\n'
      ca_cert: './client.pem'
      private_key: './client.key'
    ...

UDP:

pipelines:
  example_pipeline:
    ...
    output:
      type: socket
      network: udp
      address: '[2001:db8::1]:1234'
    ...

Unix:

pipelines:
  example_pipeline:
    ...
    output:
      type: socket
      network: unix
      address: '/tmp/filed.sock'
    ...

Config params

network string default=tcp options=tcp|udp|unix

Which network protocol to use for the outgoing connection.


address string required

Remote address to connect to.

Examples:

  • 1.2.3.4:6666
  • :6666
  • /tmp/filed.sock

delimiter string default=\n

Delimiter to append after each event. Must be exactly one byte.


ca_cert string

Client certificate in PEM encoding. This can be a path or the contents of the file.

Enables TLS. Works only when network is tcp.


private_key string

Client private key in PEM encoding. This can be a path or the contents of the file.

Enables TLS. Works only when network is tcp.


dial_timeout cfg.Duration default=5s

It defines how much time to wait for the connection.


write_timeout cfg.Duration default=5s

Timeout for writing a single batch to the socket.

Set to 0 to disable. Must be at least 1s if non-zero.


reconnect_interval cfg.Duration default=1m

The plugin reconnects to endpoint periodically using this interval. It is useful if an endpoint is a load balancer.


workers_count cfg.Expression default=gomaxprocs*4

It defines how many workers will be instantiated to send batches.


batch_size cfg.Expression default=capacity/4

A maximum quantity of events to pack into one batch.


batch_size_bytes cfg.Expression default=0

A minimum size of events in a batch to send. If both batch_size and batch_size_bytes are set, they will work together.


batch_flush_timeout cfg.Duration default=200ms

After this timeout batch will be sent even if batch isn't full.


retry int default=10

Retries of insertion. If File.d cannot insert for this number of attempts, File.d will fall with non-zero exit code or skip message (see fatal_on_failed_insert).


fatal_on_failed_insert bool default=false

After an insert error, fall with a non-zero exit code or not. A configured deadqueue disables fatal exits.


retention cfg.Duration default=1s

Retention milliseconds for retry to socket.


retention_exponentially_multiplier int default=2

Multiplier for exponential increase of retention between retries



Generated using insane-doc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

func Factory() (pipeline.AnyPlugin, pipeline.AnyConfig)

Types

type Config

type Config struct {
	// > @3@4@5@6
	// >
	// > Which network protocol to use for the outgoing connection.
	Network string `json:"network" default:"tcp" options:"tcp|udp|unix"` // *

	// > @3@4@5@6
	// >
	// > Remote address to connect to.
	// >
	// > Examples:
	// > - 1.2.3.4:6666
	// > - :6666
	// > - /tmp/filed.sock
	Address string `json:"address" required:"true"` // *

	// > @3@4@5@6
	// >
	// > Delimiter to append after each event. Must be exactly one byte.
	Delimiter  string `json:"delimiter" default:"\n"` // *
	Delimiter_ byte

	// > @3@4@5@6
	// >
	// > Client certificate in PEM encoding. This can be a path or the contents of the file.
	// >> Enables TLS. Works only when `network` is `tcp`.
	CACert string `json:"ca_cert" default:""` // *

	// > @3@4@5@6
	// >
	// > Client private key in PEM encoding. This can be a path or the contents of the file.
	// >> Enables TLS. Works only when `network` is `tcp`.
	PrivateKey string `json:"private_key" default:""` // *

	// > @3@4@5@6
	// >
	// > It defines how much time to wait for the connection.
	DialTimeout  cfg.Duration `json:"dial_timeout" default:"5s" parse:"duration"` // *
	DialTimeout_ time.Duration

	// > @3@4@5@6
	// >
	// > Timeout for writing a single batch to the socket.
	// >> Set to `0` to disable.
	// >> **Must be at least `1s` if non-zero.**
	WriteTimeout  cfg.Duration `json:"write_timeout" default:"5s" parse:"duration"` // *
	WriteTimeout_ time.Duration

	// > @3@4@5@6
	// >
	// > The plugin reconnects to endpoint periodically using this interval. It is useful if an endpoint is a load balancer.
	ReconnectInterval  cfg.Duration `json:"reconnect_interval" default:"1m" parse:"duration"` // *
	ReconnectInterval_ time.Duration

	// > @3@4@5@6
	// >
	// > It defines how many workers will be instantiated to send batches.
	WorkersCount  cfg.Expression `json:"workers_count" default:"gomaxprocs*4" parse:"expression"` // *
	WorkersCount_ int

	// > @3@4@5@6
	// >
	// > A maximum quantity of events to pack into one batch.
	BatchSize  cfg.Expression `json:"batch_size" default:"capacity/4" parse:"expression"` // *
	BatchSize_ int

	// > @3@4@5@6
	// >
	// > A minimum size of events in a batch to send.
	// > If both batch_size and batch_size_bytes are set, they will work together.
	BatchSizeBytes  cfg.Expression `json:"batch_size_bytes" default:"0" parse:"expression"` // *
	BatchSizeBytes_ int

	// > @3@4@5@6
	// >
	// > After this timeout batch will be sent even if batch isn't full.
	BatchFlushTimeout  cfg.Duration `json:"batch_flush_timeout" default:"200ms" parse:"duration"` // *
	BatchFlushTimeout_ time.Duration

	// > @3@4@5@6
	// >
	// > Retries of insertion. If File.d cannot insert for this number of attempts,
	// > File.d will fall with non-zero exit code or skip message (see fatal_on_failed_insert).
	Retry int `json:"retry" default:"10"` // *

	// > @3@4@5@6
	// >
	// > After an insert error, fall with a non-zero exit code or not. A configured deadqueue disables fatal exits.
	FatalOnFailedInsert bool `json:"fatal_on_failed_insert" default:"false"` // *

	// > @3@4@5@6
	// >
	// > Retention milliseconds for retry to socket.
	Retention  cfg.Duration `json:"retention" default:"1s" parse:"duration"` // *
	Retention_ time.Duration

	// > @3@4@5@6
	// >
	// > Multiplier for exponential increase of retention between retries
	RetentionExponentMultiplier int `json:"retention_exponentially_multiplier" default:"2"` // *
}

! config-params ^ config-params

type Plugin

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

func (*Plugin) Out

func (p *Plugin) Out(event *pipeline.Event)

func (*Plugin) Start

func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginParams)

func (*Plugin) Stop

func (p *Plugin) Stop()

Jump to

Keyboard shortcuts

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