Splunk Search

best approach for sub search with total

adomila
Explorer

Hi, I've the ff search

main search for getting total ...
| join type=outer _time 
[ search main search for getting total ... | WHERE duration>0.01 ]



RESULT:






_timeexceeded totalpercentage
2013-06-18 00:00:00 2 113 1.769912
2013-06-18 00:05:00 1 120 0.833333
2013-06-18 00:10:00 3 101 2.970297



The only difference between the main search w/ the sub search is the "WHERE duration>0.01"


My script is working fine. I just not sure if the is the best approach or if this could still be optimized by not using sub search.



tia (tnx in advance)

Tags (1)
0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

In short, try something like this:

sourcetype... | timechart span=5m count as total count(eval(duration>0.01)) as exceeded

Can't test, on the train home...

View solution in original post

martin_mueller
SplunkTrust
SplunkTrust

Great. I have converted my comment to an answer so you can mark it as solved.

0 Karma

adomila
Explorer

It works. Many thanks and be safe on your way home on a train.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

In short, try something like this:

sourcetype... | timechart span=5m count as total count(eval(duration>0.01)) as exceeded

Can't test, on the train home...

adomila
Explorer

Thanks Martin.

0 Karma

adomila
Explorer

Allow me to provide specifics. Here is the exact script:

sourcetype=abc

| bucket _time span=5m

| stats count(ref_num) as total_trans by _time

| join type=outer _time

[ search

sourcetype=abc | WHERE duration>0.01

| bucket _time span=5m

| stats sum(ref_num) as exceeded_trans by _time

]

It is noticeable that the only difference between the main and sub search is the WHERE condition that computes the exceeded transactions. How can I achieve the same RESULT:(stated above) w/o using join or sub search?

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

That depends on what you're trying to achieve.

For example, if you describe the roads you're driving on to me and ask whether they are the fastest route... I won't be able to answer that without knowing your destination.

0 Karma

adomila
Explorer

Hi Martin,
I'm trying to find out if what I have done is the best approach out there; can it be done without using join and sub search? tia.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

What are you trying to achieve?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...