Find Outliers Using Literal Quartiles

Detect outliers using fixed quartiles and the default factor using the math:iqrOutliers() function

Query

flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[/Filter/] result{{Result Set}} repo --> 1 1 --> result
flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[/Filter/] result{{Result Set}} repo --> 1 1 --> result
logscale
math:iqrOutliers(value=value, lowerQuartile=2, upperQuartile=3)

Introduction

The math:iqrOutliers() function can be used to identify events where a numeric field falls outside a range based on the interquartile range (IQR). The IQR is the difference between the upper quartile and the lower quartile. The function calculates a lower threshold by subtracting the IQR multiplied by a factor from the lower quartile. It calculates an upper threshold by adding the IQR multiplied by the same factor to the upper quartile. Events with values outside these thresholds are treated as outliers.

The IQR method is less sensitive to extreme values than methods based on average and standard deviation. This makes it well suited to skewed data such as response times, file sizes, or transaction amounts.

In this example, the math:iqrOutliers() function is used to find service requests with unusual response times, measured in seconds. The quartiles are set as literal values: the lower quartile is 2 and the upper quartile is 3, which gives an IQR of 1. With the default factor of 1.5, the lower threshold is 0.5 and the upper threshold is 4.5.

Example incoming data might look like this:

@timestampservicevalue
2026-04-10T08:00:00Zcheckout2.3
2026-04-10T08:00:00Zsearch2.8
2026-04-10T08:00:00Zlogin0.3
2026-04-10T08:01:00Zcheckout3.1
2026-04-10T08:01:00Zsearch4.5
2026-04-10T08:01:00Zlogin2.0
2026-04-10T08:02:00Zcheckout5.2
2026-04-10T08:02:00Zsearch2.6
2026-04-10T08:02:00Zlogin0.5
2026-04-10T08:03:00Zcheckout2.9
2026-04-10T08:03:00Zsearch1.2
2026-04-10T08:03:00Zlogin2.4
2026-04-10T08:04:00Zcheckout6.8
2026-04-10T08:04:00Zsearch3.4
2026-04-10T08:04:00Zlogin0.1

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[/Filter/] result{{Result Set}} repo --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[/Filter/] result{{Result Set}} repo --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    math:iqrOutliers(value=value, lowerQuartile=2, upperQuartile=3)

    Evaluates the numeric values in the value field against thresholds calculated from literal quartiles. It then returns only the events whose values fall outside these thresholds.

    The parameters are used as follows:

    The value parameter specifies the field containing the numeric values to evaluate, in this case the value field.

    The lowerQuartile parameter sets the lower quartile to the fixed value 2.

    The upperQuartile parameter sets the upper quartile to the fixed value 3.

    The IQR is calculated as 3 minus 2, which equals 1. No factor is specified, so the default factor of 1.5 is used. The lower threshold is 2 minus 1.5, which equals 0.5. The upper threshold is 3 plus 1.5, which equals 4.5. Events with a value lower than 0.5 or higher than 4.5 are returned as outliers. All other events are filtered out.

  3. Event Result set.

Summary and Results

The query is used to find events where a numeric value falls outside thresholds calculated from known, fixed quartiles.

This query is useful, for example, to detect services with abnormally slow or suspiciously fast response times. It can also be used to spot unusual file transfer sizes or transaction amounts when the typical distribution is already known from earlier analysis.

Sample output from the incoming example data:

servicevalue
login0.3
checkout5.2
checkout6.8
login0.1

Note that outliers are returned in both directions. The slow responses 5.2 and 6.8 on the checkout service are returned along with the very fast responses 0.3 and 0.1 on the login service, which might indicate failed or rejected requests. The threshold values 0.5 and 4.5 are not returned, because they do not lie outside the thresholds.

Note that literal quartiles do not adapt to changes in the data. If the distribution of the metric changes over time, the lowerQuartile and upperQuartile values must be updated manually.

For related methods, see Find Events Outside a Fixed Standard Deviation Range, which detects outliers based on a fixed average and standard deviation, and Find Temperature Readings Outside Fixed Tolerance Limits, which detects outliers based on fixed tolerance limits.