本文整理匯總了Golang中github.com/elastic/beats/libbeat/common.MapStr.Update方法的典型用法代碼示例。如果您正苦於以下問題:Golang MapStr.Update方法的具體用法?Golang MapStr.Update怎麽用?Golang MapStr.Update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/elastic/beats/libbeat/common.MapStr
的用法示例。
在下文中一共展示了MapStr.Update方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: processGroups
func processGroups(groups []string, topic string, pids map[int32]int64) []common.MapStr {
var events []common.MapStr
for _, group := range groups {
pid_offsets, err := getConsumerOffsets(group, topic, pids)
if err == nil {
for pid, offset := range pid_offsets {
event := common.MapStr{
"@timestamp": common.Time(time.Now()),
"type": "consumer",
"partition": pid,
"topic": topic,
"group": group,
"offset": offset,
}
size, ok := pids[pid]
if ok {
event.Update(common.MapStr{"lag": size - offset})
}
events = append(events, event)
}
} else {
logp.Debug("kafkabeat", "No offsets for group %s on topic %s", group, topic)
}
}
return events
}
示例2: newTCPMonitorHostJob
func newTCPMonitorHostJob(
scheme, host string, port uint16,
tls *transport.TLSConfig,
config *Config,
) (monitors.Job, error) {
typ := config.Name
timeout := config.Timeout
jobName := jobName(typ, jobType(scheme), host, []uint16{port})
validator := makeValidateConn(config)
pingAddr := net.JoinHostPort(host, strconv.Itoa(int(port)))
taskDialer, err := buildDialerChain(scheme, tls, config)
if err != nil {
return nil, err
}
return monitors.MakeSimpleJob(jobName, typ, func() (common.MapStr, error) {
event := common.MapStr{
"scheme": scheme,
"port": port,
"host": host,
}
dialer, err := taskDialer.BuildWithMeasures(event)
if err != nil {
return event, err
}
results, err := pingHost(dialer, pingAddr, timeout, validator)
event.Update(results)
return event, err
}), nil
}
示例3: getArray
func getArray(fields common.MapStr, data []byte, offset uint32) (next uint32, err bool, exists bool) {
ret := common.MapStr{}
length := binary.BigEndian.Uint32(data[offset : offset+4])
// size declared too big
if length > uint32(len(data[offset+4:])) {
return 0, true, false
}
if length > 0 {
exists = true
err := fieldUnmarshal(ret, data[offset+4:offset+4+length], 0, length, 0)
if err {
logp.Warn("Error while parsing a field array")
return 0, true, false
}
if fields == nil {
fields = ret
} else {
fields.Update(ret)
}
}
return length + 4 + offset, false, exists
}
示例4: createPingFactory
func createPingFactory(
makeDialerChain func(string) *dialchain.DialerChain,
addr connURL,
timeout time.Duration,
validator ConnCheck,
) func(*net.IPAddr) monitors.TaskRunner {
fields := common.MapStr{"scheme": addr.Scheme}
return monitors.MakePingAllIPPortFactory(fields, addr.Ports,
func(ip *net.IPAddr, port uint16) (common.MapStr, error) {
host := net.JoinHostPort(ip.String(), strconv.Itoa(int(port)))
pingAddr := net.JoinHostPort(addr.Host, strconv.Itoa(int(port)))
event := common.MapStr{}
dialer, err := makeDialerChain(host).BuildWithMeasures(event)
if err != nil {
return event, err
}
results, err := pingHost(dialer, pingAddr, timeout, validator)
event.Update(results)
return event, err
})
}