Splunk Dev

Bucketing the results based on the values of another field

macadminrohit
Contributor

I have created a query which tells me the RATIO of number of messages with different keywords in a field msg. One of the field is Response Time which will have various values. now i want the final result to be bucketed based on the response time . below is my query , which doesnt work :
index=servers sourcetype=xs_json msg="HTTP*"
| search actualTime=* | eval actualTime=round(actualTime,0) | rangemap field=actualTime T_LT_1_Sec=0-1000 1_T_5=1001-5000 5_T_15=5001-15000 default=T_GT_15
| stats count(eval(msg="HttpRequest")) AS REQUESTS count(eval(msg="HTTP Request Exceeded SLA")) AS ExceededSLA avg(actualTime) AS AvgRspTime by range Id Model

I have questions:

1) whether my Ratio calculation is correct, i.e is it giving me the right numbers?
2) Is the usage of range field is valid to bucket the results.

Tags (1)
0 Karma
1 Solution

niketn
Legend

@macadminrohit,

1) Ratio/Average is a relative term and its accuracy depends on what is your requirement. Your query currently finds the average of actualTime for each set of range, Id, Model. If this is what you need, then it is correct 🙂

2) rangemap will give you a bucket None in case actualTime is > 15000. Alternatively, you can achieve same result with case() evaluation function as well and define a default bucket for any values which do not match any of the defied cases using true() or 1==1 condition.

3) Instead of adding a pipe after your base search to filter events with actualTime field, you should move the same to the base search for better search performance i.e remove | search actualTime=* and add actualTime=* to base search.

index=servers sourcetype=xs_json msg="HTTP*" actualTime=*
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

0 Karma

niketn
Legend

@macadminrohit,

1) Ratio/Average is a relative term and its accuracy depends on what is your requirement. Your query currently finds the average of actualTime for each set of range, Id, Model. If this is what you need, then it is correct 🙂

2) rangemap will give you a bucket None in case actualTime is > 15000. Alternatively, you can achieve same result with case() evaluation function as well and define a default bucket for any values which do not match any of the defied cases using true() or 1==1 condition.

3) Instead of adding a pipe after your base search to filter events with actualTime field, you should move the same to the base search for better search performance i.e remove | search actualTime=* and add actualTime=* to base search.

index=servers sourcetype=xs_json msg="HTTP*" actualTime=*
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

chaker
Contributor

I don't know if the ratio is correct, but you could try using the bin command to bucket actualTime

http://docs.splunk.com/Documentation/Splunk/7.1.0/SearchReference/Bin

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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