Splunk Search

see results of a rex command

owie6466
Explorer

i have this rex code to extract the string from an event field:

| rex "(?\d{1,2})\s+hours?\s+ago"
| eval process=case(Time<4, "Process Up", true(), "Process down")

this is the event field:
Event
0 minutes ago, vmkid-p4rbdb03.lm.lmig.com, windows 6.3.9600.
1 minute ago, vmpid-h4eip001.lm.lmig.com, windows 6.3.9600.

What i wanted to do is extract the 1st string w/out the minute(s) ago and use an argument to check if this is less than 4, if it is i want to label it "Process up" and if not, it should be "Process down"

my code above is not working as it's marking all servers with less than 4 as Process down. that's why i wanted to see the results for the rex command

can you help me?

thank you!

Tags (1)
0 Karma
1 Solution

mayurr98
Super Champion

Try this run anywhere search:

| makeresults 
| eval data="5 minutes ago, vmkid-p4rbdb03.lm.lmig.com, windows 6.3.9600.:1 minute ago, vmpid-h4eip001.lm.lmig.com, windows 6.3.9600." 
| makemv data delim=":" 
| mvexpand data 
| rex field=data "(?<Time>\d{1,2})\s+(minute|hour)s?\s+ago" 
| eval process=if(Time<4,"Process Up","Process Down")

On your prod data you should try:

.. | rex field=_raw "(?<Time>\d{1,2})\s+(minute|hour)s?\s+ago" 
| eval process=if(Time<4,"Process Up","Process Down")

View solution in original post

0 Karma

mayurr98
Super Champion

Try this run anywhere search:

| makeresults 
| eval data="5 minutes ago, vmkid-p4rbdb03.lm.lmig.com, windows 6.3.9600.:1 minute ago, vmpid-h4eip001.lm.lmig.com, windows 6.3.9600." 
| makemv data delim=":" 
| mvexpand data 
| rex field=data "(?<Time>\d{1,2})\s+(minute|hour)s?\s+ago" 
| eval process=if(Time<4,"Process Up","Process Down")

On your prod data you should try:

.. | rex field=_raw "(?<Time>\d{1,2})\s+(minute|hour)s?\s+ago" 
| eval process=if(Time<4,"Process Up","Process Down")
0 Karma

owie6466
Explorer

thank you so much!

0 Karma

owie6466
Explorer

is there a way to make the data generic? i have multiple search results.

0 Karma

mayurr98
Super Champion

I didn't get you. could you pls elaborate ?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

.conf25 Global Broadcast: Don’t Miss a Moment

Hello Splunkers, .conf25 is only a click away.  Not able to make it to .conf25 in person? No worries, you can ...

Observe and Secure All Apps with Splunk

 Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What's New in Splunk Observability - August 2025

What's New We are excited to announce the latest enhancements to Splunk Observability Cloud as well as what is ...