Splunk Search

How to apply regex to a field in lookup file?

pavanae
Builder

I have a lookup file query as follows

| inputlookup ABCD.csv which displays the results as follows

Host

efgh
ijkl.mno.com
pqrs.tuv.net
wxyz

Now how can i add a regex to display only the hostname and avoid the extra string which ever after the dot(.). I just want to apply the regex to display the result as follows

Host

efgh
ijkl
pqrs
wxyz

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Assuming you just want to manipulate the result of the search | inputlookup ABCD.csv, try like this

| inputlookup ABCD.csv | eval Host=mvindex(split(Host,"."),0)

OR

| inputlookup ABCD.csv | rex field=Host "^(?<Host>[^\.]+)"

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Assuming you just want to manipulate the result of the search | inputlookup ABCD.csv, try like this

| inputlookup ABCD.csv | eval Host=mvindex(split(Host,"."),0)

OR

| inputlookup ABCD.csv | rex field=Host "^(?<Host>[^\.]+)"
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...