Getting Data In

Nested Loop or a Sub-search

amanno
New Member

Hi guys,

I know there has to be a straightforward way to do this in SPL just can't figure out which to use.

I have a data set like so (CSV format):

Trial Id, Size, Result, Value
1, 64, Passed, 15000
1, 64, Passed, 14957
1, 64, Failed, 15230
1, 258, Passed, 7000
1, 258, Failed, 7500
1, 258, Passed, 6950
1, 315, Failed, 2300
1, 315, Failed, 2200
1, 315, Passed, 2100

2, 64, Passed, 15095
2, 64, Passed, 14777
2, 64, Failed, 15690
2, 258, Passed, 7100
2, 258, Failed, 7250
2, 258, Passed, 6350
2, 315, Failed, 2200
2, 315, Failed, 2000
2, 315, Passed, 2195

3, 64, Passed, 15020
3, 64, Passed, 14990
3, 64, Failed, 15245
3, 258, Passed, 7012
3, 258, Failed, 7504
3, 258, Passed, 6951
3, 315, Failed, 2309
3, 315, Failed, 2211
3, 315, Passed, 2199

And I need to compute the average of all max values per size per Trial ID (for only the ones that have Result=Passed)

This is what I have so far:

index="main" Result=Passed Size=64 | stats max(Value) as max_value by "Trial Id" | stats avg(max_value) 

Which does give me the value I am looking for but only for the "Size=64" case. How do I iterate over all the different sizes, while computing the "avg(max_value)" for each of the different sizes? I then plan to chart the average max size over the "size".

Thanks for any help!

0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi amanno,
did you tried to insert also Size in stats clauses?

index="main" Result=Passed | stats max(Value) as max_value by "Trial Id" Size | stats avg(max_value)  By Size

Bye.
Giuseppe

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi amanno,
did you tried to insert also Size in stats clauses?

index="main" Result=Passed | stats max(Value) as max_value by "Trial Id" Size | stats avg(max_value)  By Size

Bye.
Giuseppe

amanno
New Member

Thank you so much Giuseppe! That is exactly what I was looking for...knew it had to be something simple. Thanks again!

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...