Splunk Search

regex exclue from IPs

Splunk_rocks
Path Finder

I have following regex which giving Cisco group name but my events containing group = 132.XX .34.34 some IPS also so i just want to show in new field only actual group name and remove the IP from results. I have tried below one but still showing IP values.

":\s+Group(\s+=\s+|\s+<)(?P[^>|^,]+)"

Group event contains.
Group = xpn
Group = blaa
Group =
Group =
Group = < ter=pan>
Group = 123.23.21.23.

i want remove IPS from my group field.

Tags (1)
0 Karma

FrankVl
Ultra Champion

First of all: I think your regex needs some work. < and > need to be escaped, and | does not work as an OR operator in the character set definition (the [...] bit). If you want anything but > and ,, just do [^\>,]. You can use tools like regex101.com to validate your regex. If you post some sample data here, people can also help with that.

How easy it is to ignore IP addresses depends on what valid group names look like. Can those start with a number? If not, then it is easy, just add a \D (any non-number character) at the start of the capturing part of your regex, to make it match only group names that don't start with a number.

If they can start with a number, it is a bit more difficult and may be simpler to just capture it incl. IP addresses and then remove anything that looks like an IP address afterwards.

| ...your base search...
| ...your rex command...
| eval Group=if(match(Group, "^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$"), null(), Group)
0 Karma
Get Updates on the Splunk Community!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...