Skip to content

Instantly share code, notes, and snippets.

@Tombar
Created December 9, 2013 22:26
Show Gist options
  • Select an option

  • Save Tombar/7882116 to your computer and use it in GitHub Desktop.

Select an option

Save Tombar/7882116 to your computer and use it in GitHub Desktop.
logstash remove fields with mutate filter
mutate {
remove_field => ['geoip.areacode', 'geoip.continent_code', 'geoip.country_code3', 'geoip.country_name', 'geoip.dma_code',
'geoip.latitude', 'geoip.longitude', 'geoip.postal_code', 'geoip.real_region_name',
'ua.minor', 'ua.major', 'ua.os_minor', 'ua.os_major', 'ua.patch', 'ua.os_name' ]
}
@Tombar

Tombar commented Dec 9, 2013

Copy link
Copy Markdown
Author

input {
stdin {
add_field => { 'geoip.areacode' => 'adas' }
add_field => { 'ua.minor' => 'asdasd' }
add_field => { 'other.field' => 'dasdas' }
}
}

filter {
mutate {
remove_field => ['geoip.areacode', 'geoip.continent_code', 'geoip.country_code3', 'geoip.country_name', 'geoip.dma_code', 'geoip.ip',
'geoip.latitude', 'geoip.longitude', 'geoip.postal_code', 'geoip.real_region_name',
'ua.minor', 'ua.major', 'ua.os_minor', 'ua.os_major', 'ua.patch', 'ua.os_name' ]
}
}

output {
stdout { }
}

@Tombar

Tombar commented Dec 9, 2013

Copy link
Copy Markdown
Author

FTR, to get it to work with a JSON hierarchy, fields must be defined with the following notation

mutate {
remove_field => [ '[geoip][continent_code]', '[geoip][country_code3]', '[geoip][country_name]', '[geoip][dma_code]', '[geoip][ip]',
'[geoip][latitude]', '[geoip][longitude]', '[geoip][postal_code]', '[geoip][real_region_name]', '[geoip][area_code]',
'[ua][minor]', '[ua][major]', '[ua][os_minor]', '[ua][os_major]', '[ua][patch]' ]

}

@ppeble

ppeble commented Jun 14, 2022

Copy link
Copy Markdown

Just wanted to say that the last comment solved my json hierarchy problem after days of fighting with it. Thank you!

@Tombar

Tombar commented Jun 14, 2022

Copy link
Copy Markdown
Author

glad this helped you :)

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