Knowledge Management

Appending tables in searches

SplnkUse
Path Finder

Hello

Is it possible to append two searches?

I have a search that ends in:

| table A B C

And I want to append to the above some values under A, B, C that I calculate.

Can you tell me please the syntax for that?

Thanks!

Labels (1)
Tags (1)
0 Karma

ldongradi_splun
Splunk Employee
Splunk Employee

| append [...] will append the inner search results to the outer search. For example: index=foo | stats count | append [index=bar | stats count]

| appendpipe [...] will prolongate the outer search with the inner search modifications, and append the results instead of replacing them. For example: ... | appendpipe [ | stats count as extracount]

| eventstats ... will add extra columns to an existing table with a treatment like a stats, without any further transformation. For example | eventstats avg(bytes) by server 

| streamstats ... will add extra columns to an existing table, but each calculated result depend on the previous results. For example:  | streamstats count as rank

For your needs, append may not be what you're looking for. The 2 searches are independant.

0 Karma

SplnkUse
Path Finder

@ITWhisperer  thanks but I cannot make it work, it seems it does not keep aliases within the brackets and run the whole thing as one, instead of each separately and then join, is there any solution?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What is the actual search that you are using?

0 Karma

SplnkUse
Path Finder

@ITWhisperer  thanks, I am trying to combine searches in the following format. I know it may be difficult to picture the below but I cannot post more exact data.

 

I think the problem is that  the:

 eval a="aaa"

is contained in two different searches and is set to different values.

Any idea?

index=a aa!="" | fields aa
| stats count by aa
| eval a="aa"
| eval Timestamp=strftime(now(),"%d/%m/%Y %H:%M:00")
| table a b c

| append [
search
index=aa or index=bbb
| eval
| stats
| eval a="aaa"
| eval Timestamp=strftime(now(),"%d/%m/%Y %H:%M:00")
| table a bb cc
]
| append [
search
index=aa or index=bbb
| eval
| stats
| eval a="aaaa"
| eval Timestamp=strftime(now(),"%d/%m/%Y %H:%M:00")
| table a bbb ccc

0 Karma

PickleRick
SplunkTrust
SplunkTrust

The syntax looks ok, but each of your subsearches returns different set of fields. If you want to have three columns as output, you have to return the same set of fields from each of subsearches. Do a rename at the end of your subsearches so that the returned fields are named consistently.

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This is the right sort of syntax - what is the issue you are facing with doing it this way?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
search
| table A B C
| append
  [search
   | table A B C]
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...