Splunk Search

Removing FQDN from field values

RanjiRaje
Explorer

Removing FQDN from field values

Hi all, can anyone help me with framing the SPL query for the below requirement.

I have a field named Host which contains multiple values. some of them includes FQDN in various format at the end of the hostname.

eg: Host (value1.corp.abc.com, value2.abc.com,  value3.corp.abc, value4.xyz.com,  value5.klm.corp, value6.internal, value7.compute.internal, etc...)

In this, I need to get Host value as (value1, value2, value3, value4, value5, value6, value7) in my result by removing all types of FQDN.

Please can you help. Thanks in advance.

 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

There may be many ways to do that.  Here's one.

...
| rex field=Host "(?<part1>[^\.]+)"
``` If the field just extracted is a number then the Host field probably is an IP address ```
| eval Host = if(isnum(part1), Host, part1)
...
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

There may be many ways to do that.  Here's one.

...
| rex field=Host "(?<part1>[^\.]+)"
``` If the field just extracted is a number then the Host field probably is an IP address ```
| eval Host = if(isnum(part1), Host, part1)
...
---
If this reply helps you, Karma would be appreciated.
0 Karma

RanjiRaje
Explorer

Hi sir, Now I got it and your command is perfectly working fine with all scenarios. thanks much

0 Karma

RanjiRaje
Explorer

Hi sir, thanks for your spontaneous reply. 

I tried with this command and it worked. But i missed to inform that I have IP address as well under host field. Please guide me on this scenario. Thanks

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...