代码拉取完成,页面将自动刷新
package logstash
import (
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/outputs"
"github.com/elastic/beats/libbeat/outputs/transport"
)
const (
minWindowSize int = 1
defaultStartMaxWindowSize int = 10
)
var debugf = logp.MakeDebug("logstash")
func init() {
outputs.RegisterType("logstash", makeLogstash)
}
func makeLogstash(
beat beat.Info,
observer outputs.Observer,
cfg *common.Config,
) (outputs.Group, error) {
if !cfg.HasField("index") {
cfg.SetString("index", -1, beat.Beat)
}
config := newConfig()
if err := cfg.Unpack(config); err != nil {
return outputs.Fail(err)
}
hosts, err := outputs.ReadHostList(cfg)
if err != nil {
return outputs.Fail(err)
}
tls, err := outputs.LoadTLSConfig(config.TLS)
if err != nil {
return outputs.Fail(err)
}
transp := &transport.Config{
Timeout: config.Timeout,
Proxy: &config.Proxy,
TLS: tls,
Stats: observer,
}
clients := make([]outputs.NetworkClient, len(hosts))
for i, host := range hosts {
var client outputs.NetworkClient
conn, err := transport.NewClient(transp, "tcp", host, config.Port)
if err != nil {
return outputs.Fail(err)
}
if config.Pipelining > 0 {
client, err = newAsyncClient(beat, conn, observer, config)
} else {
client, err = newSyncClient(beat, conn, observer, config)
}
if err != nil {
return outputs.Fail(err)
}
client = outputs.WithBackoff(client, config.Backoff.Init, config.Backoff.Max)
clients[i] = client
}
return outputs.SuccessNet(config.LoadBalance, config.BulkMaxSize, config.MaxRetries, clients)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。