Skip to content

Instantly share code, notes, and snippets.

@yaauie
Created July 22, 2020 15:50
Show Gist options
  • Save yaauie/2d00fe6f8ffff9ba73d1b78edb5c73f6 to your computer and use it in GitHub Desktop.
Save yaauie/2d00fe6f8ffff9ba73d1b78edb5c73f6 to your computer and use it in GitHub Desktop.
Example remapping the fields output by GeoIP filter for a host ip to ECS's host geo fields, as identified in the ECS compatibility mode issue https://github.com/logstash-plugins/logstash-filter-geoip/issues/163#issuecomment-592177677
filter {
geoip {
source => "[host][ip]"
target => "[@metadata][host_geoip]"
}
if [@metadata][host_geoip] {
mutate {
copy => {
"[@metadata][host_geoip][city_name]" => "[host][geo][city_name]"
"[@metadata][host_geoip][country_name]" => "[host][geo][country_name]"
"[@metadata][host_geoip][continent_name]" => "[host][geo][continent_name]"
"[@metadata][host_geoip][country_code2]" => "[host][geo][country_iso_code]"
"[@metadata][host_geoip][region_name]" => "[host][geo][region_name]"
"[@metadata][host_geoip][region_code]" => "[host][geo][region_iso_code]"
"[@metadata][host_geoip][latitude]" => "[host][geo][location][lat]"
"[@metadata][host_geoip][longitude]" => "[host][geo][location][lon]"
}
remove_field => "[@metadata][host_geoip]"
}
}
}
@Kuermel
Copy link

Kuermel commented Aug 20, 2020

The AS information are missing.

        "[@metadata][host_geoip][as_org]"         => "[host][as][organization][name]"
        "[@metadata][host_geoip][asn]"            => "[host][as][number]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment