Skip to content

Commit

Permalink
Merge branch 'main' into otel-observed-timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
kruskall authored Nov 16, 2023
2 parents 1ce4c36 + 763ed5f commit 48f7abf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
5 changes: 5 additions & 0 deletions internal/beater/beater.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,15 @@ func (s *Runner) newFinalBatchProcessor(
}
esConfig.FlushInterval = time.Second
esConfig.Config = elasticsearch.DefaultConfig()
esConfig.MaxIdleConnsPerHost = 10
if err := s.elasticsearchOutputConfig.Unpack(&esConfig); err != nil {
return nil, nil, err
}

if esConfig.MaxRequests != 0 {
esConfig.MaxIdleConnsPerHost = esConfig.MaxRequests
}

var flushBytes int
if esConfig.FlushBytes != "" {
b, err := humanize.ParseBytes(esConfig.FlushBytes)
Expand Down
34 changes: 18 additions & 16 deletions internal/elasticsearch/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ var (

// Config holds all configurable fields that are used to create a Client
type Config struct {
Hosts Hosts `config:"hosts" validate:"required"`
Protocol string `config:"protocol"`
Path string `config:"path"`
ProxyURL string `config:"proxy_url"`
ProxyDisable bool `config:"proxy_disable"`
Timeout time.Duration `config:"timeout"`
TLS *tlscommon.Config `config:"ssl"`
Username string `config:"username"`
Password string `config:"password"`
APIKey string `config:"api_key"`
Headers map[string]string `config:"headers"`
MaxRetries int `config:"max_retries"`
Hosts Hosts `config:"hosts" validate:"required"`
Protocol string `config:"protocol"`
Path string `config:"path"`
ProxyURL string `config:"proxy_url"`
ProxyDisable bool `config:"proxy_disable"`
Timeout time.Duration `config:"timeout"`
TLS *tlscommon.Config `config:"ssl"`
Username string `config:"username"`
Password string `config:"password"`
APIKey string `config:"api_key"`
Headers map[string]string `config:"headers"`
MaxRetries int `config:"max_retries"`
MaxIdleConnsPerHost int `config:",ignore"`

// CompressionLevel holds the gzip compression level used when bulk indexing
// with go-docappender; it is otherwise ignored.
Expand Down Expand Up @@ -145,9 +146,10 @@ func NewHTTPTransport(cfg *Config) (*http.Transport, error) {
dialer := transport.NetDialer(cfg.Timeout)
tlsDialer := transport.TLSDialer(dialer, tlsConfig, cfg.Timeout)
return &http.Transport{
Proxy: proxy,
Dial: dialer.Dial,
DialTLS: tlsDialer.Dial,
TLSClientConfig: tlsConfig.ToConfig(),
Proxy: proxy,
Dial: dialer.Dial,
DialTLS: tlsDialer.Dial,
TLSClientConfig: tlsConfig.ToConfig(),
MaxIdleConnsPerHost: cfg.MaxIdleConnsPerHost,
}, nil
}
9 changes: 5 additions & 4 deletions internal/elasticsearch/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ func TestBeatsConfigSynced(t *testing.T) {
// TODO(simitt): take a closer look at ES ouput changes in libbeat
// introduced with https://github.com/elastic/beats/pull/25219
localStructExceptions := map[string]interface{}{
"ssl": nil,
"timeout": nil,
"proxy_disable": nil,
"proxy_url": nil,
"ssl": nil,
"timeout": nil,
"proxy_disable": nil,
"proxy_url": nil,
"maxidleconnsperhost": nil,
}
for name, localStructField := range localStructFields {
if _, ok := localStructExceptions[name]; ok {
Expand Down

0 comments on commit 48f7abf

Please sign in to comment.