ES|QL CHANGE_POINT command
The CHANGE_POINT command requires a platinum license.
CHANGE_POINT detects spikes, dips, and change points in a metric.
CHANGE_POINT value [ON key] [AS type_name, pvalue_name]
CHANGE_POINT value [ON key] [AS type_name, pvalue_name] [BY grouping_expression1[, ..., grouping_expressionN]]
value- The column with the metric in which you want to detect a change point.
key- The column with the key to order the values by. If not specified,
@timestampis used. group- The column to group values by. When specified, change point detection is performed independently for each group.
type_name- The name of the output column with the change point type. If not specified,
typeis used. pvalue_name- The name of the output column with the p-value that indicates how extreme the change point is. If not specified,
pvalueis used.
CHANGE_POINT detects spikes, dips, and change points in a metric. The command adds columns to
the table with the change point type and p-value, that indicates how extreme the change point is
(lower values indicate greater changes).
The possible change point types are:
dip: a significant dip occurs at this change pointdistribution_change: the overall distribution of the values has changed significantlyspike: a significant spike occurs at this pointstep_change: the change indicates a statistically significant step up or down in value distributiontrend_change: there is an overall trend change occurring at this point
There must be at least 22 values for change point detection. Any values beyond the first 1,000 are ignored.
When a BY clause is provided, these rules apply per group.
The following example detects a step change in a metric:
ROW key=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]
| MV_EXPAND key
| EVAL value = CASE(key<13, 0, 50)
| CHANGE_POINT value ON key
| WHERE type IS NOT NULL
| EVAL pvalue = ROUND(pvalue, 6)
| key:integer | value:integer | type:keyword | pvalue:double |
|---|---|---|---|
| 13 | 50 | step_change | 0.0 |
The following example detects two step changes in a metric:
ROW key=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39]
| MV_EXPAND key
| EVAL value = CASE(key<13, 0, key<26, 25, 50)
| CHANGE_POINT value ON key
| WHERE type IS NOT NULL
| EVAL pvalue = ROUND(pvalue, 6)
| key:integer | value:integer | type:keyword | pvalue:double |
|---|---|---|---|
| 13 | 25 | step_change | 0.0 |
| 26 | 50 | step_change | 0.0 |
The following example detects a step change independently for each group:
ROW k=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25], location=[12,13,14]
| MV_EXPAND k
| MV_EXPAND location
| EVAL value=CASE(k<location, 0, 50)
| CHANGE_POINT value ON k BY location
| WHERE type IS NOT NULL
| pvalue = ROUND(pvalue, 6)
| k:integer | location:integer | value:integer | type:keyword | pvalue:double |
|---|---|---|---|---|
| 12 | 12 | 50 | step_change | 0.0 |
| 13 | 13 | 50 | step_change | 0.0 |
| 14 | 14 | 50 | step_change | 0.0 |
The following example detects two step changes independently for each group:
ROW k=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39], location=[12,13,14]
| MV_EXPAND k
| MV_EXPAND location
| EVAL value=CASE(k<location, 0, k<location+13, 25, 50)
| CHANGE_POINT value ON k BY location
| WHERE type IS NOT NULL
| pvalue = ROUND(pvalue, 6)
| k:integer | location:integer | value:integer | type:keyword | pvalue:double |
|---|---|---|---|---|
| 12 | 12 | 25 | step_change | 0.0 |
| 25 | 12 | 50 | step_change | 0.0 |
| 13 | 13 | 25 | step_change | 0.0 |
| 26 | 13 | 50 | step_change | 0.0 |
| 14 | 14 | 25 | step_change | 0.0 |
| 27 | 14 | 50 | step_change | 0.0 |