本文整理匯總了Golang中github.com/elastic/beats/metricbeat/mb.EventFetcher類的典型用法代碼示例。如果您正苦於以下問題:Golang EventFetcher類的具體用法?Golang EventFetcher怎麽用?Golang EventFetcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了EventFetcher類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WriteEvent
func WriteEvent(f mb.EventFetcher, t *testing.T) error {
if !*dataFlag {
t.Skip("Skip data generation tests")
}
event, err := f.Fetch()
if err != nil {
return err
}
return createEvent(event, f)
}
示例2: singleEventFetch
func (msw *metricSetWrapper) singleEventFetch(fetcher mb.EventFetcher) (common.MapStr, error) {
start := time.Now()
event, err := fetcher.Fetch()
elapsed := time.Since(start)
if err == nil {
msw.stats.Add(successesKey, 1)
} else {
msw.stats.Add(failuresKey, 1)
}
if event, err = createEvent(msw, event, err, start, elapsed); err != nil {
return nil, errors.Wrap(err, "createEvent failed")
}
return event, nil
}
示例3: WriteEvent
func WriteEvent(f mb.EventFetcher, t *testing.T) error {
if !*dataFlag {
t.Skip("Skip data generation tests")
}
event, err := f.Fetch()
if err != nil {
return err
}
path, err := os.Getwd()
if err != nil {
return err
}
fullEvent := common.MapStr{
"@timestamp": "2016-05-23T08:05:34.853Z",
"beat": common.MapStr{
"hostname": "beathost",
"name": "beathost",
},
"metricset": common.MapStr{
"host": "localhost",
"module": f.Module().Name(),
"name": f.Name(),
"rtt": 115,
},
f.Module().Name(): common.MapStr{
f.Name(): event,
},
"type": "metricsets",
}
output, _ := json.MarshalIndent(fullEvent, "", " ")
err = ioutil.WriteFile(path+"/_beat/data.json", output, 0644)
if err != nil {
return err
}
return nil
}
示例4: singleEventFetch
func (msw *metricSetWrapper) singleEventFetch(fetcher mb.EventFetcher, host string) error {
start := time.Now()
event, err := fetcher.Fetch(host)
elapsed := time.Since(start)
if err == nil {
msw.stats.Add(successesKey, 1)
} else {
msw.stats.Add(failuresKey, 1)
}
event, err = createEvent(msw, host, event, 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
}