1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
prospector_stdin.go 1.06 KB
一键复制 编辑 原始数据 按行查看 历史
package prospector
import (
"fmt"
"github.com/elastic/beats/filebeat/harvester"
"github.com/elastic/beats/filebeat/input/file"
"github.com/elastic/beats/libbeat/logp"
)
type ProspectorStdin struct {
harvester *harvester.Harvester
started bool
}
// NewProspectorStdin creates a new stdin prospector
// This prospector contains one harvester which is reading from stdin
func NewProspectorStdin(p *Prospector) (*ProspectorStdin, error) {
prospectorer := &ProspectorStdin{
started: false,
}
var err error
prospectorer.harvester, err = p.createHarvester(file.State{Source: "-"})
if err != nil {
return nil, fmt.Errorf("Error initializing stdin harvester: %v", err)
}
return prospectorer, nil
}
func (p *ProspectorStdin) LoadStates(states []file.State) error {
return nil
}
func (p *ProspectorStdin) Run() {
// Make sure stdin harvester is only started once
if !p.started {
reader, err := p.harvester.Setup()
if err != nil {
logp.Err("Error starting stdin harvester: %s", err)
return
}
go p.harvester.Harvest(reader)
p.started = true
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v5.6.10

搜索帮助