Splunk Search

Showing 0 instead of no results, how to get this line to append to another lookup?

fereze
Engager

Hi Everyone: I have this query on which is comparing the file from last week to the one of this one. I'm doing this to bring new events by date, but when there is no results found it is no showing me the Date and a 0, and I need this line to append it to another lookup.

| inputlookup append=t NEW.csv
| lookup OLD.csv UniqueID OUTPUTNEW UniqueID as NEW
| where like(ISSUE,"%Wrong%")
| where isnull(NEW)
| stats count as New_event by DATE_REPORT
| eval Date=strftime(strptime(DATE_REPORT, "%Y-%m-%d %H:%M:%S"), "%m-%d-%Y")
| fields Date New_event

 

 

I would like to get something like this:

Date                           New_event
6-23-2022               0

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use the appendpipe command to detect the absence of results and insert "dummy" results for you.

| inputlookup append=t NEW.csv
| lookup OLD.csv UniqueID OUTPUTNEW UniqueID as NEW
| where like(ISSUE,"%Wrong%")
| where isnull(NEW)
| stats count as New_event by DATE_REPORT
| eval Date=strftime(strptime(DATE_REPORT, "%Y-%m-%d %H:%M:%S"), "%m-%d-%Y")
| appendpipe [ stats count | eval DATE_REPORT=strftime(now(), "%m-%d-%Y") | eval New_event=0 | where count=0 | fields - count ]
| fields Date New_event

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Use the appendpipe command to detect the absence of results and insert "dummy" results for you.

| inputlookup append=t NEW.csv
| lookup OLD.csv UniqueID OUTPUTNEW UniqueID as NEW
| where like(ISSUE,"%Wrong%")
| where isnull(NEW)
| stats count as New_event by DATE_REPORT
| eval Date=strftime(strptime(DATE_REPORT, "%Y-%m-%d %H:%M:%S"), "%m-%d-%Y")
| appendpipe [ stats count | eval DATE_REPORT=strftime(now(), "%m-%d-%Y") | eval New_event=0 | where count=0 | fields - count ]
| fields Date New_event

 

---
If this reply helps you, Karma would be appreciated.

fereze
Engager

It works! Thanks!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...