Splunk Search

Show meesage if no results but continue applyng commands if there are results

gpincheiraa
Engager

I have a following query:

index=main source=mylogsource.log "Response Message:*" "234998102" 
| ifnoresults ---> (eval message | show message), if there are results --> continue applying the next commands
| eval number = 234998102
| rex field=_raw "(?:<balance couponType=\"Customer\">)(?P<customerCoupons>\d+)(?:</balance>)" 
| rex field=_raw "(?:<balance couponType=\"Companion\">)(?P<companionCoupons>\d+)(?:</balance>)" 
| rex field=_raw "(?:<balance couponType=\"Both\">)(?P<bothCoupons>\d+)(?:</balance>)" 
| table number, trkid, customerCoupons, companionCoupons, bothCoupons

My idea is show a message if the base search doesn't have results or continue with the commands pipe if there are results.

It is possible achieve this?

Tags (2)
0 Karma

cmerriman
Super Champion

I've never tried it in the middle of a search before, i've always tacked it onto the end if there were no results, but this is my method for that:

| appendpipe [ stats count | eval message="There is no data for this time period."  | where count==0 |table message]

Let me know if that works in the middle of your search or what happens if it doesn't.

0 Karma
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...