代码拉取完成,页面将自动刷新
package beat
import (
"errors"
"time"
"github.com/elastic/beats/libbeat/common"
)
// Event is the common event format shared by all beats.
// Every event must have a timestamp and provide encodable Fields in `Fields`.
// The `Meta`-fields can be used to pass additional meta-data to the outputs.
// Output can optionally publish a subset of Meta, or ignore Meta.
type Event struct {
Timestamp time.Time
Meta common.MapStr
Fields common.MapStr
Private interface{} // for beats private use
}
var (
errNoTimestamp = errors.New("value is no timestamp")
)
func (e *Event) GetValue(key string) (interface{}, error) {
if key == "@timestamp" {
return e.Timestamp, nil
}
return e.Fields.GetValue(key)
}
func (e *Event) PutValue(key string, v interface{}) (interface{}, error) {
if key == "@timestamp" {
switch ts := v.(type) {
case time.Time:
e.Timestamp = ts
case common.Time:
e.Timestamp = time.Time(ts)
default:
return nil, errNoTimestamp
}
}
// TODO: add support to write into '@metadata'?
return e.Fields.Put(key, v)
}
func (e *Event) Delete(key string) error {
return e.Fields.Delete(key)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。