本文整理匯總了Golang中github.com/elastic/beats/metricbeat/mb.EventsFetcher類的典型用法代碼示例。如果您正苦於以下問題:Golang EventsFetcher類的具體用法?Golang EventsFetcher怎麽用?Golang EventsFetcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了EventsFetcher類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: multiEventFetch
func (msw *metricSetWrapper) multiEventFetch(fetcher mb.EventsFetcher) ([]common.MapStr, error) {
start := time.Now()
events, err := fetcher.Fetch()
elapsed := time.Since(start)
var rtnEvents []common.MapStr
if err == nil {
msw.stats.Add(successesKey, 1)
for _, event := range events {
event, err = createEvent(msw, event, nil, start, elapsed)
if err != nil {
return nil, errors.Wrap(err, "createEvent failed")
}
rtnEvents = append(rtnEvents, event)
}
} else {
msw.stats.Add(failuresKey, 1)
event, err := createEvent(msw, nil, err, start, elapsed)
if err != nil {
return nil, errors.Wrap(err, "createEvent failed")
}
rtnEvents = append(rtnEvents, event)
}
return rtnEvents, nil
}
示例2: multiEventFetch
func (msw *metricSetWrapper) multiEventFetch(fetcher mb.EventsFetcher, host string) error {
start := time.Now()
events, err := fetcher.Fetch(host)
elapsed := time.Since(start)
if err == nil {
msw.stats.Add(successesKey, 1)
for _, event := range events {
event, err = createEvent(msw, host, event, nil, start, elapsed)
if err != nil {
logp.Warn("createEvent error: %v", err)
}
if event != nil {
msw.module.pubClient.PublishEvent(event)
msw.stats.Add(eventsKey, 1)
}
}
} else {
msw.stats.Add(failuresKey, 1)
event, err := createEvent(msw, host, nil, err, start, elapsed)
if err != nil {
logp.Warn("createEvent error: %v", err)
}
if event != nil {
msw.module.pubClient.PublishEvent(event)
msw.stats.Add(eventsKey, 1)
}
}
return nil
}
示例3: WriteEvents
func WriteEvents(f mb.EventsFetcher, t *testing.T) error {
if !*dataFlag {
t.Skip("Skip data generation tests")
}
events, err := f.Fetch()
if err != nil {
return err
}
return createEvent(events[0], f)
}