Wildcard in logstash mutate filter

This support forum board is for support questions relating to Nagios Log Server, our solution for managing and monitoring critical log data.
Locked
HASupport
Posts: 19
Joined: Wed Apr 11, 2018 2:12 pm

Wildcard in logstash mutate filter

Post by HASupport »

Hi Support,

We have more than 500 hundred network switches and we want to change the filed "type" to network.
I used following configuration but its not working.

if [host] == "10.100.250.*" { mutate { replace => { "type" => "Network" } } }
if [host] == "10.100.251.*" { mutate { replace => { "type" => "Network" } } }

Thanks,
Last edited by HASupport on Mon Jun 18, 2018 11:55 pm, edited 1 time in total.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Wildcard in logstash mutate filter

Post by mcapra »

Logstash uses the =~ operator to match regular expressions. See this page for more info:
https://www.elastic.co/guide/en/logstas ... ation.html

Try this:

Code: Select all

if [host] =~ /10\.100\.250\..*/ { mutate { replace => { "type" => "Network" } } }
if [host] =~ /10\.100\.251\..*/ { mutate { replace => { "type" => "Network" } } }
Note that I have escaped the octet separators.
Former Nagios employee
https://www.mcapra.com/
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Wildcard in logstash mutate filter

Post by cdienger »

Thanks for the assist, @mcapra!
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
HASupport
Posts: 19
Joined: Wed Apr 11, 2018 2:12 pm

Re: Wildcard in logstash mutate filter

Post by HASupport »

Thanks @mcapra, I applied and it worked
Locked