Splunk Search

How to use splunk MLTK to detect outliers in case to find latency anomalies?

amitrinx
Explorer

Hi Team, 
I have a field "duration". There are lot of APIs for which this field is populated
can i use the Detect outliers to find out out high duration instances in the last 7 days based on API name.

As i am new to this. i don't know how to start. can someone help?

Labels (1)
Tags (1)
0 Karma

amitrinx
Explorer

can i do something like this

sourcetype="something"
| fields duration, operation
| bin _time span=5m
| stats avg(duration) as avg_duration by operation, _time
| streamstats window=0 avg(avg_duration) as mean_duration stdev(avg_duration) as stdev_duration by identity_operation
| eval normalized_duration = (avg_duration - mean_duration) / stdev_duration
| eventstats avg(normalized_duration) as avg_normalized_duration by operation
| eval normalized_duration = (normalized_duration - avg_normalized_duration) / stdev(avg_normalized_duration)
| fit IsolationForestModel normalized_duration by operation
| eval anomaly = if(predicted_IsolationForestModel = 1, 0, 1)
| table identity_operation, _time, avg_duration, anomaly

as stdev is not supported in splunk what can i use instead?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

stdev is supported as an aggregation function to stats commands not a function to eval command

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

MLTK detects anomalies by looking at deviations from a model of "expected" behaviour, so the first thing you need to do is create a search which returns what you decide is normal behaviour. In your case, this could be average duration per API per hour/day/whatever time period is appropriate for your data. The tricky bit is that you may need to create a model for each API (which isn't ideal). A workaround to this is to normalise the data in some way.

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!

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

Index This | How many sevens are there between 1 and 100?

August 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...