本文整理匯總了Golang中github.com/elastic/beats/libbeat/publisher.Client.PublishEvents方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.PublishEvents方法的具體用法?Golang Client.PublishEvents怎麽用?Golang Client.PublishEvents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elastic/beats/libbeat/publisher.Client
的用法示例。
在下文中一共展示了Client.PublishEvents方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Scanner
func Scanner(config config.PathConfig, client publisher.Client) {
duration, _ := time.ParseDuration(config.Period)
ticker := time.NewTicker(duration)
defer ticker.Stop()
for {
select {
case <-ticker.C:
}
events := []common.MapStr{}
logp.Debug("mod", "Scanning glob: %s", config.Glob)
files, _ := filepath.Glob(config.Glob)
for _, file := range files {
logp.Debug("mod", "Get stats for file: %s", file)
stat, _ := os.Lstat(file)
event := common.MapStr{
"@timestamp": common.Time(time.Now()),
"type": "modbeat",
"name": stat.Name(),
"path": file,
"mode": stat.Mode(),
"modtime": stat.ModTime(),
"size": stat.Size(),
}
events = append(events, event)
}
client.PublishEvents(events)
logp.Debug("mod", "Events sent for %s files", len(events))
}
}