Splunk Search

Split and display

priya0709
Path Finder

My requirement is to display just domain (eg Corp)

From below Computername

Computername - <host>. Corp. <Domain>. Com

0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

You can use either split or rex

| rex field=Computername "[^\.]*\.(?<Corp>[^\.]*)"

OR 

| eval Corp=mvindex(split(Computername,"."),1,1)

Hope this helps

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

It isn't clear if "Computername" is part of the field you are trying to extract from or the name of the field. If it is part of the field (assuming _raw)

| rex "Computername - \w+\.(?<Corp>[^\.]+)\.Com"

 If it is the field name

| rex field=Computername "^\w+\.(?<Corp>[^\.]+)\.Com"

This assume <host> is at the beginning of Computername. If not, just remove the ^ from the beginning

Both of these assume that there are only two dots in the computername 

0 Karma

priya0709
Path Finder

Hi

Thanks for your reply

Computername is from raw dat

But actual field is 'Hostdomain' under which I want to display 'corp' from computername

Computername format - -

<HOST>. Corp. <domain>. com

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

In that case

| rex field=Hostdomain "^[^\.]+\.(?<Corp>[^\.]+)"
0 Karma

bowesmana
SplunkTrust
SplunkTrust

You can use either split or rex

| rex field=Computername "[^\.]*\.(?<Corp>[^\.]*)"

OR 

| eval Corp=mvindex(split(Computername,"."),1,1)

Hope this helps

 

Get Updates on the Splunk Community!

Unlock Database Monitoring with Splunk Observability Cloud

  In today’s fast-paced digital landscape, even minor database slowdowns can disrupt user experiences and ...

Purpose in Action: How Splunk Is Helping Power an Inclusive Future for All

At Cisco, purpose isn’t a tagline—it’s a commitment. Cisco’s FY25 Purpose Report outlines how the company is ...

[Upcoming Webinar] Demo Day: Transforming IT Operations with Splunk

Join us for a live Demo Day at the Cisco Store on January 21st 10:00am - 11:00am PST In the fast-paced world ...