Reporting

Extract Field value

Zenun
Engager

Hello Splunker,

Since I am not computer science major, I have a hard time with Regex.

I have fields value with lxw0000.usr.osd.mil, amico0000, alsedx.osd.mil and so much more with variation.

How can I extract value before the first period?

for example just

Server

lxw0000

amico0000

alsedx

when I use the  (?<server>.*).\  , it does not show the amico0000.

Your quick help will be appreciated.

Thanks.

Labels (1)
Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

It depends on what delimits your string - I have assumed either dot or space

| rex "^(?<server>[^\.\s]+)"

View solution in original post

0 Karma

s2_splunk
Splunk Employee
Splunk Employee
| makeresults 
| eval n="lxw0000.usr.osd.mil,amico0000,alsedx.osd.mil" 
| makemv delim="," n 
| rex field="n" "^(?<host>\w+)\.?"

First three lines to generate your test dataset. Will extract anything before your first "." (which is optional)

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It depends on what delimits your string - I have assumed either dot or space

| rex "^(?<server>[^\.\s]+)"
0 Karma

Zenun
Engager

Thank you both for the quick solution.  have a great day!

Tags (1)
0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...