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 Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...