Splunk Search

Return a custom table with empty results when no results on base search

matansocher
Contributor

Hi,
I have the following search, and sometimes it doesn't get any results.
When there are no values to return, I want to return a table with the fields: _time | sloc_type | upload_id
to show the user that there are no results.

My search:

index=testeda_p groupID=sloc_data 
    | search project=Periph core=pcie core_ver=1.4 sloc_type="verif" 
    | dedup _time 
    | sort -_time 
    | head 1 
    | table _time sloc_type upload_id

Thanks

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi matansocher,
try something like this

index=testeda_p groupID=sloc_data project=Periph core=pcie core_ver=1.4 sloc_type="verif" 
| dedup _time 
| sort -_time 
| append [ | stats count | eval sloc_type="No logs!", upload_id=""| table _time sloc_type upload_id ]  
| head 1 
| table _time sloc_type upload_id

Bye.
Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi matansocher,
try something like this

index=testeda_p groupID=sloc_data project=Periph core=pcie core_ver=1.4 sloc_type="verif" 
| dedup _time 
| sort -_time 
| append [ | stats count | eval sloc_type="No logs!", upload_id=""| table _time sloc_type upload_id ]  
| head 1 
| table _time sloc_type upload_id

Bye.
Giuseppe

Get Updates on the Splunk Community!

Take Your Breath Away with Splunk Risk-Based Alerting (RBA)

WATCH NOW!The Splunk Guide to Risk-Based Alerting is here to empower your SOC like never before. Join Haylee ...

SignalFlow: What? Why? How?

What is SignalFlow? Splunk Observability Cloud’s analytics engine, SignalFlow, opens up a world of in-depth ...

Federated Search for Amazon S3 | Key Use Cases to Streamline Compliance Workflows

Modern business operations are supported by data compliance. As regulations evolve, organizations must ...