func (cpu *CPU) GetCpuStatEvent(cpuStat *CpuTimes) common.MapStr { result := common.MapStr{ "user_p": cpuStat.UserPercent, "system_p": cpuStat.SystemPercent, "idle_p": cpuStat.IdlePercent, "iowait_p": cpuStat.IOwaitPercent, "irq_p": cpuStat.IrqPercent, "nice_p": cpuStat.NicePercent, "softirq_p": cpuStat.SoftIrqPercent, "steal_p": cpuStat.StealPercent, } if cpu.CpuTicks { m := common.MapStr{ "user": cpuStat.User, "system": cpuStat.Sys, "nice": cpuStat.Nice, "idle": cpuStat.Idle, "iowait": cpuStat.Wait, "irq": cpuStat.Irq, "softirq": cpuStat.SoftIrq, "steal": cpuStat.Stolen, } return common.MapStrUnion(result, m) } return result }
// annotateEvent adds fields that are common to all events. This adds the 'beat' // field that contains name and hostname. It also adds 'tags' and 'fields'. See // the documentation for Client for more information. func (c *client) annotateEvent(event common.MapStr) { // Allow an event to override the destination index for an event by setting // beat.index in an event. beatMeta := c.beatMeta if beatIfc, ok := event["beat"]; ok { ms, ok := beatIfc.(common.MapStr) if ok { // Copy beatMeta so the defaults are not changed. beatMeta = common.MapStrUnion(beatMeta, ms) } } event["beat"] = beatMeta // Add the global tags and fields defined under shipper. common.AddTags(event, c.globalEventMetadata.Tags) common.MergeFields(event, c.globalEventMetadata.Fields, c.globalEventMetadata.FieldsUnderRoot) // Add the event specific fields last so that they precedence over globals. if metaIfc, ok := event[common.EventMetadataKey]; ok { eventMetadata, ok := metaIfc.(common.EventMetadata) if ok { common.AddTags(event, eventMetadata.Tags) common.MergeFields(event, eventMetadata.Fields, eventMetadata.FieldsUnderRoot) } delete(event, common.EventMetadataKey) } }