Find API Response Times Outside Fixed Limits

Filter events with response times outside a closed range of fixed limits using the math:rangeOutliers() 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:rangeOutliers(field=responseTime, low=0, high=500)

Introduction

The math:rangeOutliers() function can be used to keep only the events where a numeric value falls outside a closed range defined by a lower and an upper bound. The closed range includes both bounds, so values equal to the bounds are not outliers.

The math:rangeOutliers() function is a filter function. It returns each kept event unchanged and in its original order, and it adds or modifies no fields. All three parameters, field, low, and high, are required. Each parameter accepts a literal value, a field reference, an arithmetic expression, or a function call.

Typical use cases include the following tasks:

  • Finding readings outside fixed tolerance limits, such as temperature, latency, or payload size.

  • Finding events outside a per-event expected range, where other fields define or calculate the bounds.

  • Excluding outliers from further analysis with the negated function !math:rangeOutliers().

In this example, the math:rangeOutliers() function is used to find API requests with response times outside the expected range of 0 to 500 milliseconds. Response times above the upper bound indicate slow requests that breach a service level objective, and negative response times indicate clock skew or instrumentation errors.

Example incoming data might look like this:

@timestampserviceendpointstatusresponseTime
2026-03-15T08:00:00Zcheckout-api/api/v1/cart200142
2026-03-15T08:01:00Zauth-api/api/v1/login2000
2026-03-15T08:02:00Zcheckout-api/api/v1/payment200-12
2026-03-15T08:03:00Zsearch-api/api/v1/search200500
2026-03-15T08:04:00Zcheckout-api/api/v1/payment2001830
2026-03-15T08:05:00Zauth-api/api/v1/token20087
2026-03-15T08:06:00Zsearch-api/api/v1/search200500.1
2026-03-15T08:07:00Zcheckout-api/api/v1/cart200231
2026-03-15T08:08:00Zcheckout-api/api/v1/payment5042405
2026-03-15T08:09:00Zauth-api/api/v1/login200312
2026-03-15T08:10:00Zsearch-api/api/v1/suggest200-0.5
2026-03-15T08:11:00Zauth-api/api/v1/token200499.9999
2026-03-15T08:12:00Zcheckout-api/api/v1/cart200<no value>
2026-03-15T08:13:00Zcheckout-api/api/v1/payment200750
2026-03-15T08:14:00Zsearch-api/api/v1/search502-
2026-03-15T08:15:00Zauth-api/api/v1/login20064

In the input listing, an empty value represents a missing responseTime field.

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:rangeOutliers(field=responseTime, low=0, high=500)

    Filters the events by checking the value of the responseTime field against the closed range from 0 to 500, and keeps only the events where the value falls outside that range.

    The low parameter sets the inclusive lower bound to 0.

    The high parameter sets the inclusive upper bound to 500.

    All three parameters are required and have no default values. For a one-sided check, set the unused bound to a large finite value, for example low=-1e308, because a missing bound is not treated as unbounded.

    For each event, the math:rangeOutliers() function converts the three values to double-precision floating-point numbers and compares them. An event is an outlier, and is kept, only if the responseTime value is less than 0 or greater than 500. Values equal to 0 or 500 are inside the range, and the function applies no tolerance margin.

    If the responseTime field is missing, non-numeric, or NaN, the event is undecided. math:rangeOutliers() treats undecided events as non-outliers and drops them.

    The function returns the kept events unchanged and in their original order. It does not add an output field.

  3. Event Result set.

Summary and Results

The query is used to identify API requests with response times outside a fixed expected range, in this case response times below 0 or above 500 milliseconds.

This query is useful, for example, to detect requests that breach a latency service level objective, find slow endpoints, or spot negative response times caused by clock skew or faulty instrumentation. The same approach applies to other measurements with fixed limits, such as payload size or hardware temperature.

Sample output from the incoming example data:

serviceendpointstatusresponseTime
checkout-api/api/v1/payment200-12
checkout-api/api/v1/payment2001830
search-api/api/v1/search200500.1
checkout-api/api/v1/payment5042405
search-api/api/v1/suggest200-0.5
checkout-api/api/v1/payment200750

Note that the closed range includes both bounds and applies no tolerance margin. The response times of exactly 0 and exactly 500, and the value 499.9999, are therefore not returned, while values just outside the limits, such as 500.1 and -0.5, are returned as outliers. The event with a missing responseTime field and the event with the value -, which many access logs use as a placeholder for an unknown value, are also dropped, because the function treats undecided events as non-outliers. Requests without a valid response time therefore need a separate check.

The /api/v1/payment endpoint of the checkout-api service appears four times in the results, three times as a slow request and once with a negative response time, which might indicate both a performance problem and a timing issue in that service.