from
Description
The from
command retrieves data from a dataset, such as a data model dataset, a CSV lookup, a KV Store lookup, a saved search, or a table dataset.
Design a search that uses the from
command to reference a dataset. Optionally add additional SPL such as lookups, eval expressions, and transforming commands to the search. Save the result as a report, alert, or dashboard panel. If you use Splunk Cloud Platform, or use Splunk Enterprise and have installed the Splunk Datasets Add-on, you can also save the search as a table dataset.
See the Usage section.
Syntax
The required syntax is in bold.
- | from
- <dataset_type>:<dataset_name> | <dataset_type> <dataset_name>
You can specify a colon ( : ) or a space between <dataset_type> and <dataset_name>.
Required arguments
- <dataset_type>
- Syntax: <dataset_type>
- Description: The type of dataset. Valid values are:
datamodel
,lookup
, andsavedsearch
. - The
datamodel
dataset type can be either a data model dataset or a table dataset. You create data model datasets with the Data Model Editor. You can create table datasets with the Table Editor if you use Splunk Cloud Platform, or use Splunk Enterprise and have installed the Splunk Datasets Add-on. - The
lookup
dataset type can be either a CSV lookup or a KV Store lookup. - The
savedsearch
dataset type is a saved search. You can usefrom
to reference any saved search as a dataset. - See About datasets in the Knowledge Manager Manual.
- <dataset_name>
- Syntax: <dataset_name>
- Description: The name of the dataset that you want to retrieve data from. If the
dataset_type
is a data model, the syntax is<datamodel_name>.<dataset_name>
. If the name of the dataset contains spaces, enclose the dataset name in quotation marks. - Example: If the data model name is
internal_server
, and the dataset name issplunkdaccess
, specifyinternal_server.splunkdaccess
for thedataset_name
.
In older versions of the Splunk software, the term "data model object" was used. That term has been replaced with "data model dataset".
Optional arguments
None.
Usage
The from
command is a generating command. It can be either report-generating or event-generating depending on the search or knowledge object that is referenced by the command. See Command types.
Generating commands use a leading pipe character and should be the first command in a search. However, you can use the from
command inside the append
command.
When you use the from
command, you must reference an existing dataset. You can reference any dataset listed in the Datasets listing page, such as data model datasets, CSV lookup files, CSV lookup definitions, and table datasets. You can also reference saved searches and KV Store lookup definitions. See View and manage datasets in the Knowledge Manager Manual.
Knowledge object dependencies
When you create a knowledge object such as a report, alert, dashboard panel, or table dataset, that knowledge object has a dependency on the referenced dataset. This is referred to as a dataset extension. When you make a change to the original dataset, such as removing or adding fields, that change propagates down to the reports, alerts, dashboard panels, and tables that have been extended from that original dataset. See Dataset extension in the Knowledge Manager Manual.
When field filtering is disabled for a data model
When you search the contents of a data model using the from
command, by default the search returns a strictly-filtered set of fields. It returns only default fields and fields that are explicitly identified in the constraint search that defines the data model.
If you have edit access to your local datamodel.conf
file, you can disable field filtering for specific data models by adding the strict_fields=false
setting to their stanzas. When you do this, | from
searches of data models with that setting return all fields related to the data model, including fields inherited from parent data models, fields extracted at search time, calculated fields, and fields derived from lookups.
Examples
1. Search a data model
Search a data model that contains internal server log events for REST API calls. In this example, internal_server
is the data model name and splunkdaccess
is the dataset inside the internal_server
data model.
| from datamodel:internal_server.splunkdaccess
2. Search a lookup file
Search a lookup file that contains geographic attributes for each country, such as continent, two-letter ISO code, and subregion.
| from lookup geo_attr_countries.csv
3. Retrieve data by using a lookup file
Search the contents of the KV store collection kvstorecoll that have a CustID
value greater than 500 and a CustName
value that begins with the letter P. The collection is referenced in a lookup table called kvstorecoll_lookup
. Using the stats
command, provide a count of the events received from the table.
| from lookup:kvstorecoll_lookup | where (CustID>500) AND (CustName="P*") | stats count
4. Retrieve data using a saved search
This search retrieves the timestamp and client IP from the saved search called mysecurityquery
.
| from savedsearch:mysecurityquery | fields _time clientip ...
The search results look something like this.
Even if the saved search is scheduled, this search is rerun, which can be expensive and lead to concurrency issues if more searches are run at the same time than the system can support. Alternatively, you can use the loadjob command instead of the from
command in conjunction with a scheduled search if you are concerned about the number and frequency of searches that your users run.
5. Specify a dataset name that contains spaces
When the name of a dataset includes spaces, enclose the dataset name in quotation marks.
| from savedsearch "Top five sourcetypes"
See also
- Commands
- datamodel
- inputlookup
- inputcsv
- lookup
- loadjob
format | fromjson |
This documentation applies to the following versions of Splunk® Enterprise: 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.3.9, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.6, 8.0.7, 8.0.8, 8.0.9, 8.0.10, 8.1.0, 8.1.1, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.1.7, 8.1.8, 8.1.9, 8.1.10, 8.1.11, 8.1.12, 8.1.13, 8.1.14, 8.2.0, 8.2.1, 8.2.2, 8.2.3, 8.2.4, 8.2.5, 8.2.6, 8.2.7, 8.2.8, 8.2.9, 8.2.10, 8.2.11, 8.2.12, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 9.0.5, 9.0.6, 9.0.7, 9.0.8, 9.0.9, 9.0.10, 9.1.0, 9.1.1, 9.1.2, 9.1.3, 9.1.4, 9.1.5, 9.1.6, 9.1.7, 9.2.0, 9.2.1, 9.2.2, 9.2.3, 9.2.4, 9.3.0, 9.3.1, 9.3.2, 9.4.0
Feedback submitted, thanks!