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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Rounding off the Splunk Dashboard Contest

What does a contest-winning Splunk dashboard look like? In this case, it isn't in a browser tab at all. It ...