Skip to content
SPL // Splunk

Using the inputlookup and outputlookup Commands

KGI Avatar

Written by: Eric Holsinger | Last Updated:

July 9, 2024
inputlookup & outputlookup

Originally Published:

June 12, 2024

Splunk Search Processing Language (SPL) is a powerful language designed to query and manipulate data within Splunk. The inputlookup and outputlookup commands play a crucial role in managing and interacting with lookup tables. These commands help users enrich their searches with external data and store search results for future reference, enhancing the overall efficiency of data operations. 

Understanding the inputlookup and outpulookup Commands in Splunk

The inputlookup command is used to retrieve data from a lookup table. Lookup tables in Splunk are CSV files that contain additional data that can be used to augment event data during searches. This command enables users to bring in external data, such as lists of known IP addresses, user information, or threat intelligence feeds, and correlate it with their search results. 

The outputlookup command allows users to write search results to a lookup table. This functionality is useful for storing intermediate search results, creating custom lookup tables, or updating existing ones with new data. It helps in maintaining data consistency and reusability across different searches and dashboards.

Some of the benefits of using the inputlookup and outputlook commands:

  • Data Enrichment: These commands allow you to enhance your search results by incorporating additional context from external data sources. 

  • Improved Reporting: Storing search results in lookup tables enables you to generate consistent reports and dashboards without rerunning intensive queries. 

  • Efficient Data Management: By saving intermediate results, you can streamline complex searches and reduce redundant data processing. 

Proper Command Syntax

Let’s go over the basic syntax for the inputlookup and outputlookup commands: 


					<search> | inputlookup <lookup_table> 


					< search> | outputlookup <lookup_table> <append=true/false> (optional)

Sample Use Cases

Example 1: Enriching Search Results with `inputlookup` 

Use Case: You have a list of known malicious IP addresses in a lookup table named `malicious_ips.csv` and want to identify events from these IPs in your access logs. 

[ | lookup malicious_ips.csv  
   | fields src_ip]  
| where user_role=admin 
| stats values(src_ip) as src_ip  values(user_name) as user_name by action  

This command will look at the events from the access_logs index. It will then pull in the data from the malicious_ips csv file, specifically the src_ip field. We then compare these values to the ones found in the same field name in the access_logs index. It then filters down to admin roles and gives a statistical grouping of the values of src_ip and user_name by action taken. The inputlookup command helped enrich the data by easily bringing in and collating the data from the csv file with the data from the index. 

Example 2: Storing Search Results with `outputlookup` 

 Use Case: You want to store the results of a search that identifies failed login attempts for further analysis. 

					index=auth_logs action=failed_login 
| stats count by user, src_ip 
| outputlookup failed_logins.csv 

This search identifies failed login attempts, aggregates them by user and source IP, and stores the results in the `failed_logins.csv` lookup table using the outputlookup command.

Example 3: Combining `inputlookup` and `outputlookup` for Data Updates 

You have a lookup table of employee details and want to update it with new entries from a recent import. 

					| inputlookup employee_details.csv 
| append [| inputlookup new_employee_import.csv] 
| dedup employee_id 
| outputlookup employee_details.csv 

This search reads the existing employee details, appends new entries from a recent import, removes duplicates, and updates the `employee_details.csv` lookup table.


In summary, inputlookup and outputlookup are powerful commands within Splunk SPL that enable efficient data enrichment and management. They enhance search capabilities by integrating external data, streamline complex search processes, and facilitate consistent reporting. Understanding and utilizing these commands effectively can significantly improve your daily operations in Splunk, making your data analysis more comprehensive and efficient. 

Helpful? Don't forget to share this post!