append command to append the results of a subsearch to the results of your current search. The append
command will run only over historical data; it will not produce correct results if used in a real-time search.
Appends subsearch results to current results.
append [subsearch-options]* subsearch
- Description: A search pipeline. Read more about how subsearches work in the Search manual.
- Syntax: maxtime=<int> | maxout=<int> | timeout=<int>
- Description: Controls how the subsearch is executed.
- Syntax: maxtime=<int>
- Description: The maximum time (in seconds) to spend on the subsearch before automatically finalizing. Defaults to 60.
- Syntax: maxout=<int>
- Description: The maximum number of result rows to output from the subsearch. Defaults to 50000.
- Syntax: timeout=<int>
- Description: The maximum time (in seconds) to wait for subsearch to fully finish. Defaults to 120.
Append the results of a subsearch to the current search as new results at the end of current results.
|This example uses the sample dataset from the tutorial. Download the data set from this topic in the tutorial and follow the instructions to upload it to Splunk. Then, run this search using the time range, Other > Yesterday.|
Count the number of different customers who purchased something from the Flower & Gift shop yesterday, and break this count down by the type of product (Candy, Flowers, Gifts, Plants, and Balloons) they purchased. Also, list the top purchaser for each type of product and how much that person bought of that product.
sourcetype=access_* action=purchase | stats dc(clientip) by category_id | append [search sourcetype=access_* action=purchase | top 1 clientip by category_id] | table category_id, dc(clientip), clientip, count
This example first searches for purchase events (
action=purchase). These results are pipped into the
stats command and the
dc() or distinct_count() function is used to count the number of different users who make purchases. The
by clause is used to break up this number based on the different category of products (
The subsearch is used to search for purchase events and count the top purchaser (based on
clientip) for each category of products. These results are added to the results of the previous search using the
table command is used to display only the category of products (
category_id), the distinct count of users who bought each type of product (
dc(clientip)), the actual user who bought the most of a product type (
clientip), and the number of each product that user bought (
You can see that the
append command just tacks on the results of the subsearch to the end of the previous search, even though the results share the same field values. It doesn't let you manipulate or reformat the output.
|This example uses the sample dataset from the tutorial but should work with any format of Apache Web access log. Download the data set from this topic in the tutorial and follow the instructions to upload it to Splunk. Then, run this search using the time range, Other > Yesterday.|
Count the number of different IP addresses who accessed the Web server and also find the user who accessed the Web server the most for each type of page request (
sourcetype=access_* | stats dc(clientip), count by method | append [search sourcetype=access_* | top 1 clientip by method]
The Web access events are piped into the
stats command and the
dc() or distinct_count() function is used to count the number of different users who accessed the site. The
count() function is used to count the total number of times the site was accessed. These numbers are separated by the page request (
The subsearch is used to find the top user for each type of page request (
append command is used to add the result of the subsearch to the bottom of the table:
The first two rows are the results of the first search. The last two rows are the results of the subsearch. Both result sets share the
Example 1: Append the current results with the tabular results of "fubar".
... | chart count by bar | append [search fubar | chart count by baz]
Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the append command.
This documentation applies to the following versions of Splunk® Enterprise: 5.0, 5.0.1, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.10, 5.0.11, 5.0.12, 5.0.13, 5.0.14, 5.0.15, 5.0.16, 5.0.17, 5.0.18