Splunk Search

Search events based on lookup field and display lookup row even if nothing found

nomad1981
Explorer

I have a lookup file which contains a list of jobnames, description and their SLAs.

Example: 

jobNameDescriptionSLA
job1Example108.00
job2Example210.00
job5Example305.00

 

My index data (index=autosys) contains events for hundreds of jobs, their status and updated time. 

An event example would be: job1, FAILED, 07.00

I'm trying to write a query to output the below. However, there are cases where there won't be any events for a specific job. In that case, I need to display, "NOT RUNNING"

jobNameDescriptionSLAStatusUpdatetime
job1Example108.00FAILED07.00
job2Example210.00SUCCESS09.00
job5Example305.00NOT RUNNINGNULL

 

I'm using the following query, but it is not displaying the row that does not have any event/data in the index

 

 

 

| inputlookup append=t lookup_job.csv | table jobName, SLA, Description
| join jobName [search index=autosys  | inputlookup lookup_job.csv | fields jobName ]]
| table jobName, Description, SLA, Status, Updatedtime

 

 

 

 

 

Labels (1)
0 Karma
1 Solution

nomad1981
Explorer

I was able to sort it out using join type=left

 

| inputlookup append=t lookup_job.csv | table jobName, SLA, Description
| join type=left jobName [search index=autosys  | inputlookup lookup_job.csv | fields jobName ]]
| table jobName, Description, SLA, Status, Updatedtime

 

View solution in original post

0 Karma

to4kawa
Ultra Champion

index=autosys [|inputlookup lookup_job.csv | table jobName| format]
| lookup lookup_job.csv  jobName OUTPUT Description, SLA
| table jobName, Description, SLA, Status, Updatedtime

0 Karma

nomad1981
Explorer

Unfortunately, the query does not return the item from the lookup if there are no events found. 

Also, I need the results to the displayed in the same order of jobName as per what is in the lookup file

0 Karma

to4kawa
Ultra Champion
index=autosys 
| table jobName Status Updatedtime
| inputlookup append=t lookup_job.csv
| table jobName, Description, SLA, Status, Updatedtime
| fillnull status value="NOT RUNNING"
| stats values(*) as * by jobName

Like this?

0 Karma

nomad1981
Explorer

That query returns all jobs in found in the search index autosys. 

I need to return the data that's in the lookup table as is and add 2 additional columns (Status and Updatedtime) which is found in the index data. If the search does not find the Status and Updatedtime for a specfic job, that job should still appear in the table with the 2 fields showing as "NOT RUNNING". 

 

0 Karma

to4kawa
Ultra Champion

try where

0 Karma

nomad1981
Explorer

I was able to sort it out using join type=left

 

| inputlookup append=t lookup_job.csv | table jobName, SLA, Description
| join type=left jobName [search index=autosys  | inputlookup lookup_job.csv | fields jobName ]]
| table jobName, Description, SLA, Status, Updatedtime

 

0 Karma
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...