Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions plugin/output/elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,18 @@ Process ES response and report errors, if any.

<br>

**`ban_period`** *`cfg.Duration`* *`default=10s`*

Period for which addresses will be banned in case of unavailability.
If set to 0, circuit breaker is disabled.

<br>

**`reconnect_interval`** *`cfg.Duration`* *`default=5s`*

Interval for reconnecting to addresses that are unavailable during initialization.

<br>


<br>*Generated using [__insane-doc__](https://github.com/vitkovskii/insane-doc)*
33 changes: 27 additions & 6 deletions plugin/output/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ type Config struct {
// >
// > Process ES response and report errors, if any.
ProcessResponse bool `json:"process_response" default:"true"` // *

// > @3@4@5@6
// >
// > Period for which addresses will be banned in case of unavailability.
// > If set to 0, circuit breaker is disabled.
BanPeriod cfg.Duration `json:"ban_period" default:"10s" parse:"duration"` // *
BanPeriod_ time.Duration

// > @3@4@5@6
// >
// > Interval for reconnecting to addresses that are unavailable during initialization.
ReconnectInterval cfg.Duration `json:"reconnect_interval" default:"5s" parse:"duration"` // *
ReconnectInterval_ time.Duration
}

type KeepAliveConfig struct {
Expand Down Expand Up @@ -243,8 +256,17 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
if len(p.config.IndexValues) == 0 {
p.config.IndexValues = append(p.config.IndexValues, "@time")
}
if p.config.ReconnectInterval_ < 1 {
p.logger.Fatal("'reconnect_interval' can't be <1")
}
if p.config.BanPeriod_ < 0 {
p.logger.Fatal("'ban_period' cant't be <0")
}

ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

p.prepareClient()
p.prepareClient(ctx)

p.maintenance(nil)

Expand Down Expand Up @@ -295,9 +317,6 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
onError,
)

ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

p.batcher.Start(ctx)
}

Expand All @@ -315,11 +334,13 @@ func (p *Plugin) registerMetrics(ctl *metric.Ctl) {
p.indexingErrorsMetric = ctl.RegisterCounter("output_elasticsearch_index_error_total", "Number of elasticsearch indexing errors")
}

func (p *Plugin) prepareClient() {
func (p *Plugin) prepareClient(ctx context.Context) {
config := &xhttp.ClientConfig{
Endpoints: prepareEndpoints(p.config.Endpoints, p.config.IngestPipeline),
ConnectionTimeout: p.config.ConnectionTimeout_ * 2,
AuthHeader: p.getAuthHeader(),
BanPeriod: p.config.BanPeriod_,
ReconnectInterval: p.config.ReconnectInterval_,
KeepAlive: &xhttp.ClientKeepAliveConfig{
MaxConnDuration: p.config.KeepAlive.MaxConnDuration_,
MaxIdleConnDuration: p.config.KeepAlive.MaxIdleConnDuration_,
Expand All @@ -335,7 +356,7 @@ func (p *Plugin) prepareClient() {
}

var err error
p.client, err = xhttp.NewClient(config)
p.client, err = xhttp.NewClient(ctx, config)
if err != nil {
p.logger.Fatal("can't create http client", zap.Error(err))
}
Expand Down
13 changes: 13 additions & 0 deletions plugin/output/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,17 @@ After a non-retryable write error, fall with a non-zero exit code or not

<br>

**`ban_period`** *`cfg.Duration`* *`default=10s`*

Period for which addresses will be banned in case of unavailability.
If set to 0, circuit breaker is disabled.

<br>

**`reconnect_interval`** *`cfg.Duration`* *`default=5s`*

Interval for reconnecting to addresses that are unavailable during initialization.

<br>

<br>*Generated using [__insane-doc__](https://github.com/vitkovskii/insane-doc)*
34 changes: 28 additions & 6 deletions plugin/output/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,19 @@ type Config struct {
// >
// > After a non-retryable write error, fall with a non-zero exit code or not
Strict bool `json:"strict" default:"false"` // *

// > @3@4@5@6
// >
// > Period for which addresses will be banned in case of unavailability.
// > If set to 0, circuit breaker is disabled.
BanPeriod cfg.Duration `json:"ban_period" default:"10s" parse:"duration"` // *
BanPeriod_ time.Duration

// > @3@4@5@6
// >
// > Interval for reconnecting to addresses that are unavailable during initialization.
ReconnectInterval cfg.Duration `json:"reconnect_interval" default:"5s" parse:"duration"` // *
ReconnectInterval_ time.Duration
}

type KeepAliveConfig struct {
Expand Down Expand Up @@ -212,13 +225,23 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
p.registerMetrics(params.MetricCtl)
p.mu = &sync.Mutex{}

if p.config.ReconnectInterval_ < 1 {
p.logger.Fatal("'reconnect_interval' can't be <1")
}
if p.config.BanPeriod_ < 0 {
p.logger.Fatal("'ban_period' cant't be <0")
}

var err error
p.encoder, err = NewEncoder(p.config.Encoding)
if err != nil {
p.logger.Fatal("can't create encoder", zap.Error(err))
}

p.prepareClient()
ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

p.prepareClient(ctx)

p.logger.Info("starting batcher", zap.Duration("timeout", p.config.BatchFlushTimeout_))

Expand Down Expand Up @@ -267,9 +290,6 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
onError,
)

ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

p.batcher.Start(ctx)
}

Expand All @@ -286,11 +306,13 @@ func (p *Plugin) registerMetrics(ctl *metric.Ctl) {
p.sendErrorMetric = ctl.RegisterCounterVec("output_http_send_error_total", "Total HTTP send errors", "status_code")
}

func (p *Plugin) prepareClient() {
func (p *Plugin) prepareClient(ctx context.Context) {
config := &xhttp.ClientConfig{
Endpoints: p.prepareEndpoints(),
ConnectionTimeout: p.config.ConnectionTimeout_ * 2,
AuthHeader: p.getAuthHeader(),
BanPeriod: p.config.BanPeriod_,
ReconnectInterval: p.config.ReconnectInterval_,
KeepAlive: &xhttp.ClientKeepAliveConfig{
MaxConnDuration: p.config.KeepAlive.MaxConnDuration_,
MaxIdleConnDuration: p.config.KeepAlive.MaxIdleConnDuration_,
Expand All @@ -306,7 +328,7 @@ func (p *Plugin) prepareClient() {
}

var err error
p.client, err = xhttp.NewClient(config)
p.client, err = xhttp.NewClient(ctx, config)
if err != nil {
p.logger.Fatal("can't create http client", zap.Error(err))
}
Expand Down
13 changes: 13 additions & 0 deletions plugin/output/loki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,18 @@ Multiplier for exponential increase of retention between retries

<br>

**`ban_period`** *`cfg.Duration`* *`default=10s`*

Period for which addresses will be banned in case of unavailability.
If set to 0, circuit breaker is disabled.

<br>

**`reconnect_interval`** *`cfg.Duration`* *`default=5s`*

Interval for reconnecting to addresses that are unavailable during initialization.

<br>


<br>*Generated using [__insane-doc__](https://github.com/vitkovskii/insane-doc)*
36 changes: 29 additions & 7 deletions plugin/output/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ type Config struct {
// >
// > Multiplier for exponential increase of retention between retries
RetentionExponentMultiplier int `json:"retention_exponentially_multiplier" default:"2"` // *

// > @3@4@5@6
// >
// > Period for which addresses will be banned in case of unavailability.
// > If set to 0, circuit breaker is disabled.
BanPeriod cfg.Duration `json:"ban_period" default:"10s" parse:"duration"` // *
BanPeriod_ time.Duration

// > @3@4@5@6
// >
// > Interval for reconnecting to addresses that are unavailable during initialization.
ReconnectInterval cfg.Duration `json:"reconnect_interval" default:"5s" parse:"duration"` // *
ReconnectInterval_ time.Duration
}

type AuthStrategy byte
Expand Down Expand Up @@ -259,7 +272,18 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP

p.labels = p.parseLabels()

p.prepareClient()
if p.config.ReconnectInterval_ < 1 {
p.logger.Fatal("'reconnect_interval' can't be <1")
}
if p.config.BanPeriod_ < 0 {
p.logger.Fatal("'ban_period' cant't be <0")
}

ctx, cancel := context.WithCancel(context.Background())
p.ctx = ctx
p.cancel = cancel

p.prepareClient(ctx)

batcherOpts := &pipeline.BatcherOptions{
PipelineName: params.PipelineName,
Expand Down Expand Up @@ -303,10 +327,6 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
onError,
)

ctx, cancel := context.WithCancel(context.Background())
p.ctx = ctx
p.cancel = cancel

p.batcher.Start(ctx)
}

Expand Down Expand Up @@ -430,20 +450,22 @@ func (p *Plugin) registerMetrics(ctl *metric.Ctl) {
p.sendErrorMetric = ctl.RegisterCounterVec("output_loki_send_error_total", "Total Loki send errors", "status_code")
}

func (p *Plugin) prepareClient() {
func (p *Plugin) prepareClient(ctx context.Context) {
config := &xhttp.ClientConfig{
Endpoints: []string{fmt.Sprintf("%s/loki/api/v1/push", p.config.Address)},
ConnectionTimeout: p.config.ConnectionTimeout_ * 2,
AuthHeader: p.getAuthHeader(),
CustomHeaders: p.getCustomHeaders(),
BanPeriod: p.config.BanPeriod_,
ReconnectInterval: p.config.ReconnectInterval_,
KeepAlive: &xhttp.ClientKeepAliveConfig{
MaxConnDuration: p.config.KeepAlive.MaxConnDuration_,
MaxIdleConnDuration: p.config.KeepAlive.MaxIdleConnDuration_,
},
}

var err error
p.client, err = xhttp.NewClient(config)
p.client, err = xhttp.NewClient(ctx, config)
if err != nil {
p.logger.Fatal("can't create http client", zap.Error(err))
}
Expand Down
13 changes: 13 additions & 0 deletions plugin/output/splunk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,18 @@ or the "event" key with any of its subkeys.

<br>

**`ban_period`** *`cfg.Duration`* *`default=10s`*

Period for which addresses will be banned in case of unavailability.
If set to 0, circuit breaker is disabled.

<br>

**`reconnect_interval`** *`cfg.Duration`* *`default=5s`*

Interval for reconnecting to addresses that are unavailable during initialization.

<br>


<br>*Generated using [__insane-doc__](https://github.com/vitkovskii/insane-doc)*
35 changes: 29 additions & 6 deletions plugin/output/splunk/splunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,19 @@ type Config struct {
// > Supports copying whole original event, but does not allow to copy directly to the output root
// > or the "event" key with any of its subkeys.
CopyFields []CopyField `json:"copy_fields" slice:"true"` // *

// > @3@4@5@6
// >
// > Period for which addresses will be banned in case of unavailability.
// > If set to 0, circuit breaker is disabled.
BanPeriod cfg.Duration `json:"ban_period" default:"10s" parse:"duration"` // *
BanPeriod_ time.Duration

// > @3@4@5@6
// >
// > Interval for reconnecting to addresses that are unavailable during initialization.
ReconnectInterval cfg.Duration `json:"reconnect_interval" default:"5s" parse:"duration"` // *
ReconnectInterval_ time.Duration
}

type KeepAliveConfig struct {
Expand Down Expand Up @@ -235,7 +248,18 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
p.avgEventSize = params.PipelineSettings.AvgEventSize
p.config = config.(*Config)
p.registerMetrics(params.MetricCtl)
p.prepareClient()

if p.config.ReconnectInterval_ < 1 {
p.logger.Fatal("'reconnect_interval' can't be <1")
}
if p.config.BanPeriod_ < 0 {
p.logger.Fatal("'ban_period' cant't be <0")
}

ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

p.prepareClient(ctx)

for _, cf := range p.config.CopyFields {
if cf.To == "" {
Expand Down Expand Up @@ -296,9 +320,6 @@ func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginP
onError,
)

ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel

p.batcher.Start(ctx)
}

Expand All @@ -319,11 +340,13 @@ func (p *Plugin) registerMetrics(ctl *metric.Ctl) {
)
}

func (p *Plugin) prepareClient() {
func (p *Plugin) prepareClient(ctx context.Context) {
config := &xhttp.ClientConfig{
Endpoints: []string{p.config.Endpoint},
ConnectionTimeout: p.config.RequestTimeout_,
AuthHeader: "Splunk " + p.config.Token,
BanPeriod: p.config.BanPeriod_,
ReconnectInterval: p.config.ReconnectInterval_,
KeepAlive: &xhttp.ClientKeepAliveConfig{
MaxConnDuration: p.config.KeepAlive.MaxConnDuration_,
MaxIdleConnDuration: p.config.KeepAlive.MaxIdleConnDuration_,
Expand All @@ -338,7 +361,7 @@ func (p *Plugin) prepareClient() {
}

var err error
p.client, err = xhttp.NewClient(config)
p.client, err = xhttp.NewClient(ctx, config)
if err != nil {
p.logger.Fatal("can't create http client", zap.Error(err))
}
Expand Down
Loading
Loading