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!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...