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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...