Skip to content
SPL // Splunk

Using the from Command

KGI Avatar
 

Written by: Carlos Diez | Last Updated:

 
March 12, 2025
 
Search Command Of The Week: from
 
 

Originally Published:

 
February 27, 2025

Splunk Processing Language (SPL) is a powerful query language used to search, analyze, and visualize data in Splunk. It enables users to extract meaningful insights from vast datasets quickly. Among its many commands, the from command plays a crucial role in querying datasets efficiently. 

The from command is essential in SPL because it allows users to retrieve data from structured datasets stored within Splunk. Understanding how to use this command properly can significantly enhance your Splunk experience. 

It is important to note that from is also used as an argument in other commands, such as tstats, where it specifies the dataset being queried. However, in this post, we focus on from as a standalone command. 

Understanding the from Command

The from command retrieves data from a dataset instead of using traditional search pipelines. It is useful for structured datasets, such as those aligned with CIM, KV stores, saved searches, or lookup tables. 

Unlike traditional Splunk searches, which often rely on the search command, from allows you to work with predefined datasets efficiently. This is particularly useful when dealing with large data volumes and data models. 

Proper Syntax

To use the from command correctly, follow this syntax: 

				
					| from datamodel <datamodel_name>.<dataset_name> 
				
			

Key components of this syntax include: 

  • datamodel_name: The name of the data model you are querying. 
  • dataset_name: The specific dataset within the data model. 
  • Optional filters and transformations can be applied after retrieving the dataset. 

For example: 

				
					| from datamodel Web.Web_Transactions 
				
			

This command retrieves all data from the Web_Transactions dataset within the Web data model. 

When querying KV stores or lookup tables, the syntax follows a similar structure: 

				
					| from lookup <lookup_name> 
				
			

or

				
					| from kvstore <kvstore_name> 
				
			

These variations allow users to retrieve structured data efficiently from different sources within Splunk. 

Benefits of Using the from Command

Using the from command in Splunk has several advantages: 

  • Optimized Performance: Queries on structured datasets execute more efficiently than raw index searches. 
  • Improved Readability: Using the from command makes searches easier to understand and maintain. 
  • Consistency in Data Analysis: Since it retrieves data from predefined datasets, it ensures consistency across multiple searches and reports.

Example Use Cases

Example #1: Querying the Web Data Model

A security analyst wants to analyze web transactions for potential threats, such as excessive 404 errors, which may indicate broken links, unauthorized access attempts, or web scraping activity. 

				
					| from datamodel Web.Web_Transactions 
| search status=404 
| stats count by uri 
				
			

This query retrieves web transaction data from the Splunk Common Information Model (CIM). It then filters the results to show only HTTP 404 errors, which represent pages not found. Finally, it counts the occurrences of each URI to identify frequently requested but missing resources, helping analysts determine potential issues or attack patterns. 

Example #2: Extracting Authentication Failures

An administrator needs to track failed authentication attempts to detect brute-force attacks or unauthorized access attempts. 

				
					| from datamodel Authentication.Default_Authentication 
| search action=failure 
| stats count by user 
				
			

This query retrieves authentication data from the Authentication data model. It filters for failed authentication attempts (action=failure) and then groups and counts them by user. This allows administrators to identify accounts experiencing excessive failed logins, which may indicate a user struggling with credentials or a possible cyberattack targeting specific accounts. 

Example #3: Querying a Lookup Table

A security team wants to quickly reference known malicious IP addresses from an external threat intelligence lookup table and filter them based on severity. 

				
					| from lookup malicious_ips 
| search category=high_risk 
| table ip, category, description 
				
			

This query retrieves data from a predefined lookup table called malicious_ips, which contains a list of known threat actors’ IP addresses. The search filters for entries categorized as “high risk,” ensuring only the most critical threats are examined. Finally, the query presents a table with relevant fields—IP address, category, and description—to provide a concise summary for security analysts monitoring potential threats. 

Conclusion

The from command is a valuable addition to Splunk SPL. It improves performance, readability, and data consistency by querying structured datasets efficiently. 

Key Takeaways:
  • The from command retrieves structured data from data models, KV stores, and lookup tables in Splunk. 
  • It enhances performance and ensures consistency in searches. 
  • Using the Splunk Common Information Model improves data analysis and reporting. 

By incorporating the from command into your Splunk queries, you can work with structured data more effectively and gain deeper insights with optimized searches. 

To access more Splunk searches, check out Atlas Search Library, which is part of the Atlas Platform. Specifically, Atlas Search Library offers a curated list of optimized searches. These searches empower Splunk users without requiring SPL knowledge. Furthermore, you can create, customize, and maintain your own search library. By doing so, you ensure your users get the most from using Splunk.

Atlas Search Library
Helpful? Don't forget to share this post!
LinkedIn
Reddit
Email
Facebook