1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
connector.go 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
package module
import (
"github.com/elastic/beats/libbeat/beat"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/processors"
)
// Connector configures ann establishes a beat.Client for publishing events
// to the publisher pipeline.
type Connector struct {
pipeline beat.Pipeline
processors *processors.Processors
eventMeta common.EventMetadata
dynamicFields *common.MapStrPointer
}
type connectorConfig struct {
Processors processors.PluginConfig `config:"processors"`
common.EventMetadata `config:",inline"` // Fields and tags to add to events.
}
func NewConnector(pipeline beat.Pipeline, c *common.Config, dynFields *common.MapStrPointer) (*Connector, error) {
config := connectorConfig{}
if err := c.Unpack(&config); err != nil {
return nil, err
}
processors, err := processors.New(config.Processors)
if err != nil {
return nil, err
}
return &Connector{
pipeline: pipeline,
processors: processors,
eventMeta: config.EventMetadata,
dynamicFields: dynFields,
}, nil
}
func (c *Connector) Connect() (beat.Client, error) {
return c.pipeline.ConnectWith(beat.ClientConfig{
EventMetadata: c.eventMeta,
Processor: c.processors,
DynamicFields: c.dynamicFields,
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.1.0

搜索帮助