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!

How to Get Started with Splunk Data Management Pipeline Builders (Edge Processor & ...

If you want to gain full control over your growing data volumes, check out Splunk’s Data Management pipeline ...

Out of the Box to Up And Running - Streamlined Observability for Your Cloud ...

  Tech Talk Streamlined Observability for Your Cloud Environment Register    Out of the Box to Up And Running ...

Splunk Smartness with Brandon Sternfield | Episode 3

Hello and welcome to another episode of "Splunk Smartness," the interview series where we explore the power of ...