Splunk Search

Query partially if csv doesn't exist. -- Looking for IF-ELSE scenario with eval

aravindsurya77
Observer

My query looks like this

index=* sourcetype="MYSOURCE"  | table company_id | dedup company_id | where company_id != "-"
| lookup companyid_companyname_usercount.csv CompanyId as company_id OUTPUT Name
| table company_id Name | sort Name

 

The first part of the query is 

index=* sourcetype="MYSOURCE"  | table company_id | dedup company_id | where company_id != "-"

 

second part

| lookup companyid_companyname.csv CompanyId as company_id OUTPUT Name
| table company_id Name | sort Name

 

Requirement: I want to perform the second part of my query only if 'companyid_companyname.csv' exists. other wise just return the list of company IDs. 

 

I have tried using the IF in eval, but not sure how the else part of the query can workout. 

Any thoughts and help is highly appreciated

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The if function does not support conditional command execution.
The lookup file must exist for the lookup command to function.

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

aravindsurya77
Observer

@richgalloway  thanks for the input!

How about using a 'WHERE' clause? is it still impossible to execute a command conditionally using the WHERE clause?

0 Karma

richgalloway
SplunkTrust
SplunkTrust
SPL does not support conditional command execution. It is not a programming language.
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...

Join Us at the Builder Bar at .conf24 – Empowering Innovation and Collaboration

What is the Builder Bar? The Builder Bar is more than just a place; it's a hub of creativity, collaboration, ...

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...