Get geoip Country from other objects if not present (#1659)
This commit is contained in:
parent
73f336363a
commit
39da36361c
|
@ -77,8 +77,20 @@ func GeoIpCity(field string, p *types.Event, ctx interface{}) (map[string]string
|
||||||
log.Debugf("Unable to enrich ip '%s'", ip)
|
log.Debugf("Unable to enrich ip '%s'", ip)
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
if record.Country.IsoCode != "" {
|
||||||
ret["IsoCode"] = record.Country.IsoCode
|
ret["IsoCode"] = record.Country.IsoCode
|
||||||
ret["IsInEU"] = strconv.FormatBool(record.Country.IsInEuropeanUnion)
|
ret["IsInEU"] = strconv.FormatBool(record.Country.IsInEuropeanUnion)
|
||||||
|
} else if record.RegisteredCountry.IsoCode != "" {
|
||||||
|
ret["IsoCode"] = record.RegisteredCountry.IsoCode
|
||||||
|
ret["IsInEU"] = strconv.FormatBool(record.RegisteredCountry.IsInEuropeanUnion)
|
||||||
|
} else if record.RepresentedCountry.IsoCode != "" {
|
||||||
|
ret["IsoCode"] = record.RepresentedCountry.IsoCode
|
||||||
|
ret["IsInEU"] = strconv.FormatBool(record.RepresentedCountry.IsInEuropeanUnion)
|
||||||
|
} else {
|
||||||
|
ret["IsoCode"] = ""
|
||||||
|
ret["IsInEU"] = strconv.FormatBool(false)
|
||||||
|
}
|
||||||
|
|
||||||
ret["Latitude"] = fmt.Sprintf("%f", record.Location.Latitude)
|
ret["Latitude"] = fmt.Sprintf("%f", record.Location.Latitude)
|
||||||
ret["Longitude"] = fmt.Sprintf("%f", record.Location.Longitude)
|
ret["Longitude"] = fmt.Sprintf("%f", record.Location.Longitude)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue