Splunk Search

What is the best way to remove dots from domain?

bosseres
Contributor

Hello everyone!

What is the best way to remove dots from domain in field?

for example | eval field = lower(mvindex(split(field, "."), 0)) removes just 1 dot, and what if 2+ dots in domain?

Labels (2)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@bosseres 

if you want to just replace the value you can use replace function.

Like

 |eval field = replace(field,"\.","")

 

Can you please try this?

| makeresults | eval _raw = "field
abc.com
1.abc.com
2.1.abc.com
3.2.1.abc.com"| multikv forceheader=1
 |eval field = replace(field,"\.","")

 

if it's still not working, please provide your expected output for below sample data.

abc.com
1.abc.com
2.1.abc.com
3.2.1.abc.com

 

Thanks
KV
If any of my replies help you to solve the problem Or gain knowledge, an upvote would be appreciated.

bosseres
Contributor

I mean I want to remove part after dot

(for example google.domain.domain - must become google, google.domain1.domain2.domain3 must become google too, etc)

0 Karma

isoutamo
SplunkTrust
SplunkTrust

You could also use rex with sed mode like

 

....
| rex mode=sed field=<your field> "s/([^\.]+)(\..*)/$1/g"

 

kamlesh_vaghela
SplunkTrust
SplunkTrust

@bosseres 

Your search will work fine as you are selecting the first index after the split.

| eval field = lower(mvindex(split(field, "."), 0))

 

| makeresults | eval _raw = "field
abc.com
google.domain.domain
google.domain1.domain2.domain3
3.2.1.abc.com"| multikv forceheader=1
 | eval field = lower(mvindex(split(field, "."), 0))

 

Screenshot 2022-10-21 at 12.57.21 PM.png

 

🙂  

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...