Splunk Search

Running separate searches from a base search?

szabados
Communicator

I have a long search, where in the first part, I'm filtering down lots of data, and doing lookup, eval, etc, let's call this my base search
At the end, I want to apply stats to this data set, actually three different functions, and have the results in a table.
I'm able to do this, by running the base search 3 times, applying one of the stats function, and appending it to the other results, like this:

| basesearch | stats 1
| append [|basesearch | stats 2]
| append [|basesearch | stats 3]

Obviously, this is a huge overhead of running the same search 3 times in subsearches. I can't use a datamodel, because the parameters of my subsearch are dynamically populated, and it would be almost impossible to create all the summaries for all the possible values.

Is there any way, to do something like this?

| basesearch
| stats1
| append [| stats2 appended to the data yielded from the base search at the beginning]
| append [| stats3 appended to the data yielded from the base search at the beginning]

Thanks

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

How about this (works best if you've filtered down number of rows after base search signifacantly)

| basesearch | eval exclude=1
| appendpipe [| stats 1 | eval exclude=0 ]
 | appendpipe [| where exclude=1  | stats 2  | eval exclude=0 ]
| appendpipe [| where exclude=1  | stats 3  | eval exclude=0 ]
| where exclude=0

View solution in original post

0 Karma

somesoni2
SplunkTrust
SplunkTrust

How about this (works best if you've filtered down number of rows after base search signifacantly)

| basesearch | eval exclude=1
| appendpipe [| stats 1 | eval exclude=0 ]
 | appendpipe [| where exclude=1  | stats 2  | eval exclude=0 ]
| appendpipe [| where exclude=1  | stats 3  | eval exclude=0 ]
| where exclude=0
0 Karma

szabados
Communicator

Thanks, exactly what I needed!

0 Karma

snoobzilla
Builder

Can you add eval/case statements that allow you to do stats2 and stats3 at the same time as you do stats 1?

There was a great presentation on this at .conf2016 by Nick from Sideview. May be worth a look.

https://conf.splunk.com/sessions/2016-sessions.html#search=Let%20Stats%20Sort%20Them%20Out%3A%20Buil...

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

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 ...