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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...