func MapHostInfo()

in metric/system/host/host.go [30:68]


func MapHostInfo(info types.HostInfo, fqdn string) mapstr.M {
	name := info.Hostname
	if fqdn != "" {
		name = fqdn
	}

	data := mapstr.M{
		"host": mapstr.M{
			"name":         strings.ToLower(name),
			"hostname":     info.Hostname,
			"architecture": info.Architecture,
			"os": mapstr.M{
				"platform": info.OS.Platform,
				"version":  info.OS.Version,
				"family":   info.OS.Family,
				"name":     info.OS.Name,
				"kernel":   info.KernelVersion,
			},
		},
	}

	// Optional params
	if info.UniqueID != "" {
		_, _ = data.Put("host.id", info.UniqueID)
	}
	if info.Containerized != nil {
		_, _ = data.Put("host.containerized", *info.Containerized)
	}
	if info.OS.Codename != "" {
		_, _ = data.Put("host.os.codename", info.OS.Codename)
	}
	if info.OS.Build != "" {
		_, _ = data.Put("host.os.build", info.OS.Build)
	}
	if info.OS.Type != "" {
		_, _ = data.Put("host.os.type", info.OS.Type)
	}
	return data
}