Find Temperature Readings Outside Fixed Tolerance Limits

Filter events with numeric values 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=temperature, low=0, high=10)

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 temperature readings from refrigeration units in a cold storage facility that fall outside the allowed range of 0 to 10 degrees Celsius.

Example incoming data might look like this:

@timestampsensor_idlocationtemperature
2026-03-15T08:00:00Zfridge-01warehouse-a4.2
2026-03-15T08:05:00Zfridge-02warehouse-a0
2026-03-15T08:10:00Zfridge-03warehouse-b-1.5
2026-03-15T08:15:00Zfridge-01warehouse-a10
2026-03-15T08:20:00Zfridge-04warehouse-b12.8
2026-03-15T08:25:00Zfridge-02warehouse-a6.7
2026-03-15T08:30:00Zfridge-05warehouse-c10.1
2026-03-15T08:35:00Zfridge-03warehouse-b3.9
2026-03-15T08:40:00Zfridge-04warehouse-b15.3
2026-03-15T08:45:00Zfridge-05warehouse-c8.4
2026-03-15T08:50:00Zfridge-01warehouse-a-0.2
2026-03-15T08:55:00Zfridge-02warehouse-a9.9999
2026-03-15T09:00:00Zfridge-03warehouse-b<no value>
2026-03-15T09:05:00Zfridge-04warehouse-b11
2026-03-15T09:10:00Zfridge-05warehouse-cERR
2026-03-15T09:15:00Zfridge-01warehouse-a2.3

In the input listing, an empty value represents a missing temperature 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=temperature, low=0, high=10)

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

    The field parameter specifies the value to test, in this example the temperature field. This is the unnamed parameter, so the query can also be written as math:rangeOutliers(temperature, low=0, high=10).

    The low parameter sets the inclusive lower bound to 0.

    The high parameter sets the inclusive upper bound to 10.

    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 high=1e308, because a missing bound is not treated as unbounded.

    For each event, the 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 temperature value is less than 0 or greater than 10. Values equal to 0 or 10 are inside the range, and the function applies no tolerance margin.

    If the temperature field is missing, non-numeric, or NaN, the event is undecided. The function 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 sensor readings that fall outside a fixed tolerance range, in this case refrigeration temperatures below 0 or above 10 degrees Celsius.

This query is useful, for example, to monitor cold chain compliance, detect failing refrigeration units, or trigger alerts when goods are at risk of freezing or spoiling. The same approach applies to other measurements with fixed limits, such as response latency or payload size.

Sample output from the incoming example data:

sensor_idlocationtemperature
fridge-03warehouse-b-1.5
fridge-04warehouse-b12.8
fridge-05warehouse-c10.1
fridge-04warehouse-b15.3
fridge-01warehouse-a-0.2
fridge-04warehouse-b11

Note that the closed range includes both bounds and applies no tolerance margin, so the readings of exactly 0 from fridge-02 and exactly 10 from fridge-01 and the value 9.9999 are not returned, while values just outside the limits, such as 10.1 and -0.2, are returned as outliers. The event from fridge-03 with a missing temperature field and the event from fridge-05 with the non-numeric value ERR are also dropped, because the function treats undecided events as non-outliers, so faulty or empty readings need a separate check. The sensor fridge-04 in warehouse-b appears three times in the results, which might indicate a recurring problem with that unit rather than a single deviation.

For related methods that detect outliers based on a statistical baseline instead of fixed tolerance limits, see ???, which uses a fixed average and standard deviation, and ???, which uses literal quartiles and the interquartile range.