Skip to content

Commit 9f01187

Browse files
committed
Restructure change_point docs to new structure
1 parent 55a2426 commit 9f01187

File tree

4 files changed

+107
-2
lines changed

4 files changed

+107
-2
lines changed

docs/reference/query-languages/esql/README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,23 @@ The static content exists in this directory and can be edited by hand.
33
However, the sub-directories `_snippets`, `images` and `kibana` contain mostly
44
generated content.
55

6+
## Static content
7+
8+
The root `esql` directory and the following two subdirectories contain static content:
9+
* `commands` - contains the static content for the ES|QL commands.
10+
This content will typically contain mostly include directives for content in the `_snippets` or `images` directories.
11+
* `functions-operators` - contains the static content for the ES|QL functions and operators.
12+
Again this will contain mostly include directives for content in the `_snippets` or `images` directories.
13+
14+
## Mixed static and generated content
15+
16+
Generated content is created by running the ESQL tests in the `x-pack/plugin/esql` module.
17+
It will be written into three subdirectories of the `esql` directory:
18+
619
### _snippets
720

8-
In `_snippets` there are files that can be included within other files
9-
using the [File Inclusion](https://elastic.github.io/docs-builder/syntax/file_inclusion/)
21+
In `_snippets` there are files that can be included within other files using the
22+
[File Inclusion](https://elastic.github.io/docs-builder/syntax/file_inclusion/)
1023
feature of the Elastic Docs V3 system.
1124
Most, but not all, files in this directory are generated.
1225
In particular the directories `_snippets/functions/*` and `_snippets/operators/*`
@@ -34,6 +47,19 @@ To regenerate the files for all functions run all of ESQL's tests using gradle:
3447
./gradlew :x-pack:plugin:esql:test
3548
```
3649

50+
#### Commands
51+
52+
The `_snippets/commands` directory contains the content for the ES|QL commands.
53+
There are two subdirectories, one static and one generated:
54+
* `layout` - contains the static content for the ES|QL commands.
55+
The files in this directory are the main content for the documentation for the commands.
56+
They are not generated, and so this is the primary place to edit the content, or add new commands.
57+
* `examples` - contains the generated content for the ES|QL commands.
58+
The files in this directory are generated from the test `CommandsDocsTests` in the `x-pack/plugin/esql` module.
59+
The structure of the subdirectories mimics the csv-spec files and test tags used in the tests.
60+
61+
Including generated examples in the command documentation is done by using the include directive.
62+
3763
### images
3864

3965
The `images` directory contains `functions` and `operators` sub-directories with
@@ -48,3 +74,14 @@ The `kibana` directory contains `definition` and `docs` sub-directories that are
4874
* `kibana/docs` - the inline docs for kibana
4975

5076
These are also generated as part of the unit tests described above.
77+
78+
## Tutorials
79+
80+
### Adding a new command
81+
82+
When adding a new command, for example adding the `CHANGE_POINT` comamand, do the following:
83+
1. Create a new file in the `_snippets/commands/layout` directory with the name of the command, for example `change_point.md`.
84+
2. Add the content for the command to the file. See other files in this directory for examples.
85+
3. Add the command to the list in `_snippets/lists/processing-commands-md`.
86+
4. Add an include directive to the `commands/processing-commands.md` file to include the new command.
87+
5. Add tested examples to the `_snippets/commands/examples` directory. See below for details.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## `CHANGE_POINT` [esql-change_point]
2+
3+
::::{warning}
4+
This functionality is in technical preview and may be
5+
changed or removed in a future release. Elastic will work to fix any
6+
issues, but features in technical preview are not subject to the support
7+
SLA of official GA features.
8+
::::
9+
10+
`CHANGE_POINT` detects spikes, dips, and change points in a metric.
11+
12+
**Syntax**
13+
14+
```esql
15+
CHANGE_POINT value [ON key] [AS type_name, pvalue_name]
16+
```
17+
18+
**Parameters**
19+
20+
`value`
21+
: The column with the metric in which you want to detect a change point.
22+
23+
`key`
24+
: The column with the key to order the values by. If not specified, `@timestamp` is used.
25+
26+
`type_name`
27+
: The name of the output column with the change point type. If not specified, `type` is used.
28+
29+
`pvalue_name`
30+
: The name of the output column with the p-value that indicates how extreme the change point is. If not specified, `pvalue` is used.
31+
32+
**Description**
33+
34+
`CHANGE_POINT` detects spikes, dips, and change points in a metric. The command adds columns to
35+
the table with the change point type and p-value, that indicates how extreme the change point is
36+
(lower values indicate greater changes).
37+
38+
The possible change point types are:
39+
* `dip`: a significant dip occurs at this change point
40+
* `distribution_change`: the overall distribution of the values has changed significantly
41+
* `spike`: a significant spike occurs at this point
42+
* `step_change`: the change indicates a statistically significant step up or down in value distribution
43+
* `trend_change`: there is an overall trend change occurring at this point
44+
45+
::::{note}
46+
There must be at least 22 values for change point detection. Fewer than 1,000 is preferred.
47+
::::
48+
49+
**Examples**
50+
51+
The following example shows the detection of a step change:
52+
53+
```
54+
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]
55+
| MV_EXPAND key
56+
| EVAL value = CASE(key<13, 0, 42)
57+
| CHANGE_POINT value ON key
58+
| WHERE type IS NOT NULL
59+
;
60+
```
61+
62+
| key:integer | value:integer | type:keyword | pvalue:double |
63+
|-------------|---------------|--------------|---------------|
64+
| 13 | 42 | step_change | 0.0 |

docs/reference/query-languages/esql/_snippets/lists/processing-commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* [`CHANGE_POINT`](../../commands/processing-commands.md#esql-change_point)
12
* [`DISSECT`](../../commands/processing-commands.md#esql-dissect)
23
* [`DROP`](../../commands/processing-commands.md#esql-drop)
34
* [`ENRICH`](../../commands/processing-commands.md#esql-enrich)

docs/reference/query-languages/esql/commands/processing-commands.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ mapped_pages:
1717
:::{include} ../_snippets/lists/processing-commands.md
1818
:::
1919

20+
:::{include} ../_snippets/commands/layout/change_point.md
21+
:::
22+
2023
:::{include} ../_snippets/commands/layout/dissect.md
2124
:::
2225

0 commit comments

Comments
 (0)