Splunk Search

How to remove data after the first period?

jpfrancetic
Path Finder

Hi Splunk Community,

I am trying to remove the data in a field after the first period. my field looks like this:

24611_abce.XXX.AAA.com
24612_r1q2e3.XXX.AAA.com
null
null
4iop45_q7w8e9.XXX.AAA.com
hki90lhf3_m1n2b3.QQQQ.AAA.com

 

I would like to remove everything after the first period for every row but the pattterns at the end do not match after the first period. It should look like this: 

24611_abce
24612_r1q2e3
null
null
4iop45_q7w8e9
hki90lhf3_m1n2b3

 

thanks in advance!

Labels (3)
0 Karma
1 Solution

mayurr98
Super Champion

 

In your environment, you should try:

<your search>
| rex field=<fieldname> "^(?<custom_fieldname>[^\.]+)"

 

try this run anywhere search:

 

| makeresults 
| eval data="24611_abce.XXX.AAA.com,24612_r1q2e3.XXX.AAA.com,null,null,4iop45_q7w8e9.XXX.AAA.com,hki90lhf3_m1n2b3.QQQQ.AAA.com" 
| makemv data delim="," 
| mvexpand data 
| rex field=data "^(?<data>[^\.]+)"

 

let me know if this helps!

 

View solution in original post

0 Karma

mayurr98
Super Champion

 

In your environment, you should try:

<your search>
| rex field=<fieldname> "^(?<custom_fieldname>[^\.]+)"

 

try this run anywhere search:

 

| makeresults 
| eval data="24611_abce.XXX.AAA.com,24612_r1q2e3.XXX.AAA.com,null,null,4iop45_q7w8e9.XXX.AAA.com,hki90lhf3_m1n2b3.QQQQ.AAA.com" 
| makemv data delim="," 
| mvexpand data 
| rex field=data "^(?<data>[^\.]+)"

 

let me know if this helps!

 

0 Karma

jpfrancetic
Path Finder

This worked like a charm. Thank you very much

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

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...

SignalFlow: What? Why? How?

What is SignalFlow? Splunk Observability Cloud’s analytics engine, SignalFlow, opens up a world of in-depth ...