Splunk Search

"search base=X" not working with append

ChrisCLewis
Communicator

I am using the "search base=X" approach to generate stats.

When I try to run two searches using append (or join etc) I am only getting stats from the first listed query, even if I change the order of their order. I can run the queries in separate panels and get results so am confident that the issue isn't with the searches themselves.
Multiple cannot be used in the same panel (I have tried loadjob without success).

Many thanks for any pointers / tricks I have missed in getting "search base=X" and append to work together

Tags (2)
0 Karma

ChrisCLewis
Communicator

This is the append query, I originally tried it with |table instead of |fields but makes no difference.

|search Q IN ("AB", "CD") | stats count as number by month | fillnull value="0" created code description month uniques comment number volume
| eval code = "Q1"
| eval created = strftime(time(), "%Y-%m-%d %H:%M")
| eval description = "All about Q"
| fields created code description month uniques comment number volume
|append
[|search Q IN ("EF", "GH")

| makemv delim=";" mvfield | mvexpand mvfield
| eval check = mvfield
| lookup some.csv check OUTPUT check as check_csv
| where check like check_csv
| stats count as number by month | fillnull value="0" created code description month uniques comment number volume
| eval code = "R1"
| eval created = strftime(time(), "%Y-%m-%d %H:%M")
| eval description = "all about the R"
| fields created code description month uniques comment number volume ]
|table created code description month uniques comment number volume

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

Alright. So there is no grouping at the end of the search by combining both results. so initial questions are invalidated and fillnull will not help.
By looking at the search only - created, code, description, month, number are the fields available in the output.
You had already mentioned that the searches are executing fine when run separately. Are these searches using same time range? Is that from time token or explicitly mentioned in the search using earliest & latest?

Just for testing, would you mind running the below search and check if you are able to see the dummy values ?

|search Q IN ("AB", "CD") | stats count as number by month
| eval code = "Q1"
| eval created = strftime(time(), "%Y-%m-%d %H:%M")
| eval description = "All about Q"
| fields created code description month uniques comment number volume
|append 
[|makeresults|eval created="dummy",code="Dummy",description="Dummy",month="Dummy",number="Dummy"|fields - _time]
Happy Splunking!
0 Karma

ChrisCLewis
Communicator

The time frame is defined in the base search, currently a token but have also used explicit range too.

The dummy values do appear with the |makeresults.

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

Thanks Chris. Can we just run this as well and see the dummy value under field second appears in some of the events

|search Q IN ("AB", "CD") | stats count as number by month 
| eval code = "Q1"
| eval created = strftime(time(), "%Y-%m-%d %H:%M")
| eval description = "All about Q"
| fields created code description month number
|append 
[|search Q IN ("EF", "GH") 
| makemv delim=";" mvfield | mvexpand mvfield 
| eval check = mvfield 
| lookup some.csv check OUTPUT check as check_csv 
| where check like check_csv
| stats count as number by month 
| eval code = "R1"
| eval created = strftime(time(), "%Y-%m-%d %H:%M")
| eval description = "all about the R" 
| fields created code description month number|eval second="Dummy" ]
|table created code description month number,second
Happy Splunking!
0 Karma

ChrisCLewis
Communicator

Just run now and only results for Q are shown, nothing for R (including "second")

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

Chris, its bit strange.
Are you really getting results for exactly same search if they are running separately? Also did the appended search run in search window and not in a dashboard?

Happy Splunking!
0 Karma

ChrisCLewis
Communicator

Good morning,
yes - getting exactly the same results when running separately - all I did was to copy the queries to a new dashboard and add in the append element.

The original searches worked whilst appended in search - the base search does a lot of work which means the queries are now greatly shortened and use different field names etc so they only work with the base search.

It is very odd, I've used append a lot but first time using base search

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

Ok, so you are running it in a dashboard. What if you run the entire search with append in a search window?

Happy Splunking!
0 Karma

renjith_nair
SplunkTrust
SplunkTrust

@ChrisCLewis,
- Do you have a common field in both search which is used in the stats grouping? If not , rename one of them.
- If there are null values in the group by field, fillnull them with a value.

Please provide the search you are using if possible after masking any confidential data.

Happy Splunking!
0 Karma

ChrisCLewis
Communicator

Many thanks for the speedy reply.
All field names are "in common" and have just updated with fillnull - unfortunately still only getting the results from the first query.

0 Karma

renjith_nair
SplunkTrust
SplunkTrust

Do you mind sharing the search you are currently using with append?

Happy Splunking!
0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...