Forecast Values With A Renamed Output Field

Predict and forecast seasonal values in a custom field using the statistics:holtWinters() function

Query

flowchart LR; repo{{Events}}:::entry 1{{Aggregate}} 2{{Aggregate}} result{{Result Set}}:::entry repo --> 1 1 --> 2 2 --> result
flowchart LR; repo{{Events}}:::entry 1{{Aggregate}} 2{{Aggregate}} result{{Result Set}}:::entry repo --> 1 1 --> 2 2 --> result
logscale
sort(@timestamp, order=asc)
| statistics:holtWinters(field=value, cycleLength=2, as=myForecast)

Introduction

The statistics:holtWinters() function can be used to model and forecast a series of numeric values. The function uses the Holt-Winters method to produce forecasts. This method applies exponential smoothing to each of three components:

  • The level, which is the smoothed average value without the seasonal effect.

  • The trend, which is the change in level from one event to the next.

  • The seasonal component, which is a pattern that repeats every cycleLength events.

The statistics:holtWinters() function returns a prediction for each input event after a warm-up period and adds forecast events after the last input event. This makes it useful for forecasting periodic metrics, extending time series graphs with a short forecast, and finding anomalies by comparing actual values with predicted values.

In this example, the statistics:holtWinters() function is used to return predictions and a forecast of the number of escalated support tickets per shift. The as parameter renames the output field to myForecast.

The data contains one event for each 12-hour shift. The night shift starts at 20:00 and the day shift starts at 08:00. The day shift consistently has more escalated tickets than the night shift, so the pattern repeats every two events.

Example incoming data might look like this:

@timestampshiftvalue
2026-03-01T20:00:00Znight10
2026-03-02T08:00:00Zday12
2026-03-02T20:00:00Znight9
2026-03-03T08:00:00Zday13
2026-03-03T20:00:00Znight11
2026-03-04T08:00:00Zday14

Step-by-Step

  1. Starting with the source repository events.

  2. flowchart LR; repo{{Events}}:::entry 1{{Aggregate}} 2{{Aggregate}} result{{Result Set}}:::entry repo --> 1 1 --> 2 2 --> result class 1 highlight;
    flowchart LR; repo{{Events}}:::entry 1{{Aggregate}} 2{{Aggregate}} result{{Result Set}}:::entry repo --> 1 1 --> 2 2 --> result class 1 highlight;
    logscale
    sort(@timestamp, order=asc)

    Sorts the events by the @timestamp field in ascending order, so that the oldest event comes first.

    Sorting is required, because statistics:holtWinters() processes events in the order that it receives them and treats each event as one step in the series.

    As statistics:holtWinters() is an aggregate function, it must be placed after another aggregate function, such as sort(), bucket(), or groupBy().

    Note that sort() returns a maximum of 200 events by default. For longer series, set the limit parameter, for example, to max.

  3. flowchart LR; repo{{Events}}:::entry 1{{Aggregate}} 2{{Aggregate}} result{{Result Set}}:::entry repo --> 1 1 --> 2 2 --> result class 2 highlight;
    flowchart LR; repo{{Events}}:::entry 1{{Aggregate}} 2{{Aggregate}} result{{Result Set}}:::entry repo --> 1 1 --> 2 2 --> result class 2 highlight;
    logscale
    | statistics:holtWinters(field=value, cycleLength=2, as=myForecast)

    Applies Holt-Winters triple exponential smoothing to the values in the value field and returns the predictions and the forecast in a new field named myForecast.

    The function uses the following parameters:

    • The field parameter specifies the input field with the values to model, in this example value. The function removes events with a missing or non-numeric value in this field.

    • The cycleLength parameter specifies the number of events in one cycle. The value 2 matches the alternating night and day shifts. The value counts events, not time units.

    • The as parameter renames the output field to myForecast. If the parameter is not specified, statistics:holtWinters() returns the values in a field named _prediction.

    As no other parameters are specified, statistics:holtWinters() uses the following default values:

    The statistics:holtWinters() function first uses 2 ร— cycleLength events, in this example four events, as a warm-up to learn the seasonal pattern. It then adds a prediction to each later input event and finally adds the forecast event after the last input event.

  4. Event Result set.

Summary and Results

The query is used to model the number of escalated support tickets per shift, to return a prediction for each shift after the warm-up, and to forecast the number of tickets for the next shift.

This query is useful, for example, to plan staffing for upcoming shifts, or to detect shifts where the actual number of escalated tickets differs significantly from the predicted number.

Sample output from the incoming example data:

shiftvaluemyForecastย 
2026-03-01T20:00:00Znight10<no value>
2026-03-02T08:00:00Zday12<no value>
2026-03-02T20:00:00Znight9<no value>
2026-03-03T08:00:00Zday13<no value>
2026-03-03T20:00:00Znight119.410829834119513
2026-03-04T08:00:00Zday1413.134062139661907
2026-03-04T20:00:00Z<no value><no value>10.308574238130804

Note that the first four events are warm-up events without the myForecast field, and that the last event is a forecast event that contains only the myForecast and @timestamp fields. The forecast timestamp is 12 hours after the last input event, based on the gap between the first two events.

Also note that the model counts events, not time, so the data must contain exactly one event for each shift. A large difference between the value field and the myForecast field indicates an unusual event.