Skip to content

Commit 0f51bc2

Browse files
lcawlszabosteve
andauthored
[DOCS] Move anomaly detection job resource definitions into APIs (#49700)
Co-Authored-By: István Zoltán Szabó <[email protected]>
1 parent 87f9c16 commit 0f51bc2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1007
-829
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/ml/job/config/Detector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
/**
3535
* Defines the fields and functions used in the analysis. A combination of <code>field_name</code>,
3636
* <code>by_field_name</code> and <code>over_field_name</code> can be used depending on the specific
37-
* function chosen. For more information see
38-
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-job-resource.html#ml-detectorconfig">configuring
39-
* detectors</a> and <a href="https://www.elastic.co/guide/en/elastic-stack-overview/current/ml-functions.html">detector functions</a>.
37+
* function chosen. For more information see the
38+
* <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html">create anomaly detection
39+
* jobs API</a> and <a href="https://www.elastic.co/guide/en/elastic-stack-overview/current/ml-functions.html">detector functions</a>.
4040
*/
4141
public class Detector implements ToXContentObject {
4242

docs/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ buildRestTests.expectedUnconvertedCandidates = [
2929
'reference/ml/anomaly-detection/apis/get-category.asciidoc',
3030
'reference/ml/anomaly-detection/apis/get-influencer.asciidoc',
3131
'reference/ml/anomaly-detection/apis/get-job-stats.asciidoc',
32+
'reference/ml/anomaly-detection/apis/get-job.asciidoc',
3233
'reference/ml/anomaly-detection/apis/get-overall-buckets.asciidoc',
3334
'reference/ml/anomaly-detection/apis/get-record.asciidoc',
3435
'reference/ml/anomaly-detection/apis/get-snapshot.asciidoc',

docs/reference/ml/anomaly-detection/apis/close-job.asciidoc

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,15 @@ results the job might have recently produced or might produce in the future.
6060
==== {api-path-parms-title}
6161

6262
`<job_id>`::
63-
(Required, string) Identifier for the {anomaly-job}. It can be a job
64-
identifier, a group name, or a wildcard expression.
63+
(Required, string)
64+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-wildcard]
6565

6666
[[ml-close-job-query-parms]]
6767
==== {api-query-parms-title}
6868

6969
`allow_no_jobs`::
70-
(Optional, boolean) Specifies what to do when the request:
71-
+
72-
--
73-
* Contains wildcard expressions and there are no jobs that match.
74-
* Contains the `_all` string or no identifiers and there are no matches.
75-
* Contains wildcard expressions and there are only partial matches.
76-
77-
The default value is `true`, which returns an empty `jobs` array
78-
when there are no matches and the subset of results when there are partial
79-
matches. If this parameter is `false`, the request returns a `404` status code
80-
when there are no matches or only partial matches.
81-
--
70+
(Optional, boolean)
71+
include::{docdir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
8272

8373
`force`::
8474
(Optional, boolean) Use to close a failed job, or to forcefully close a job

docs/reference/ml/anomaly-detection/apis/datafeedresource.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ A {dfeed} resource has the following properties:
5050
`script_fields`::
5151
(object) Specifies scripts that evaluate custom expressions and returns
5252
script fields to the {dfeed}.
53-
The <<ml-detectorconfig,detector configuration objects>> in a job can contain
53+
The detector configuration objects in a job can contain
5454
functions that use these script fields.
5555
For more information, see
5656
{stack-ov}/ml-configuring-transform.html[Transforming Data With Script Fields].

docs/reference/ml/anomaly-detection/apis/delete-job.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ separated list.
3939
==== {api-path-parms-title}
4040

4141
`<job_id>`::
42-
(Required, string) Identifier for the {anomaly-job}.
42+
(Required, string)
43+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
4344

4445
[[ml-delete-job-query-parms]]
4546
==== {api-query-parms-title}

docs/reference/ml/anomaly-detection/apis/flush-job.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ opened again before analyzing further data.
3737
==== {api-path-parms-title}
3838

3939
`<job_id>`::
40-
(string) Required. Identifier for the job.
40+
(Required, string)
41+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
4142

4243
[[ml-flush-job-query-parms]]
4344
==== {api-query-parms-title}

docs/reference/ml/anomaly-detection/apis/forecast.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ See {stack-ov}/ml-overview.html#ml-forecasting[Forecasting the future].
2929
===============================
3030
3131
* If you use an `over_field_name` property in your job, you cannot create a
32-
forecast. For more information about this property, see <<ml-job-resource>>.
32+
forecast. For more information about this property, see <<ml-put-job>>.
3333
* The job must be open when you create a forecast. Otherwise, an error occurs.
3434
===============================
3535

3636
[[ml-forecast-path-parms]]
3737
==== {api-path-parms-title}
3838

3939
`<job_id>`::
40-
(Required, string) Identifier for the job.
40+
(Required, string)
41+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
4142

4243
[[ml-forecast-request-body]]
4344
==== {api-request-body-title}

docs/reference/ml/anomaly-detection/apis/get-bucket.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ bucket.
3636
==== {api-path-parms-title}
3737

3838
`<job_id>`::
39-
(Required, string) Identifier for the {anomaly-job}.
39+
(Required, string)
40+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
4041

4142
`<timestamp>`::
4243
(Optional, string) The timestamp of a single bucket result. If you do not

docs/reference/ml/anomaly-detection/apis/get-category.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ For more information about categories, see
3535
==== {api-path-parms-title}
3636

3737
`<job_id>`::
38-
(Required, string) Identifier for the {anomaly-job}.
38+
(Required, string)
39+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
3940

4041
`<category_id>`::
4142
(Optional, long) Identifier for the category. If you do not specify this

docs/reference/ml/anomaly-detection/apis/get-influencer.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ privileges. See <<security-privileges>> and
2727
==== {api-path-parms-title}
2828

2929
`<job_id>`::
30-
(Required, string) Identifier for the {anomaly-job}.
30+
(Required, string)
31+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
3132

3233
[[ml-get-influencer-request-body]]
3334
==== {api-request-body-title}

docs/reference/ml/anomaly-detection/apis/get-job-stats.asciidoc

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,24 @@ IMPORTANT: This API returns a maximum of 10,000 jobs.
4040
==== {api-path-parms-title}
4141

4242
`<job_id>`::
43-
(Optional, string) An identifier for the {anomaly-job}. It can be a
44-
job identifier, a group name, or a wildcard expression. If you do not specify
45-
one of these options, the API returns statistics for all {anomaly-jobs}.
43+
(Optional, string)
44+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-default]
4645

4746
[[ml-get-job-stats-query-parms]]
4847
==== {api-query-parms-title}
4948

5049
`allow_no_jobs`::
51-
(Optional, boolean) Specifies what to do when the request:
52-
+
53-
--
54-
* Contains wildcard expressions and there are no jobs that match.
55-
* Contains the `_all` string or no identifiers and there are no matches.
56-
* Contains wildcard expressions and there are only partial matches.
57-
58-
The default value is `true`, which returns an empty `jobs` array
59-
when there are no matches and the subset of results when there are partial
60-
matches. If this parameter is `false`, the request returns a `404` status code
61-
when there are no matches or only partial matches.
62-
--
50+
(Optional, boolean)
51+
include::{docdir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
6352

6453
[[ml-get-job-stats-results]]
6554
==== {api-response-body-title}
6655

6756
The API returns the following information:
6857

6958
`jobs`::
70-
(array) An array of {anomaly-job} statistics objects.
71-
For more information, see <<ml-jobstats>>.
59+
(array)
60+
include::{docdir}/ml/ml-shared.asciidoc[tag=jobs-stats-anomaly-detection]
7261

7362
[[ml-get-job-stats-response-codes]]
7463
==== {api-response-codes-title}

docs/reference/ml/anomaly-detection/apis/get-job.asciidoc

Lines changed: 127 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,101 @@ IMPORTANT: This API returns a maximum of 10,000 jobs.
4040
==== {api-path-parms-title}
4141

4242
`<job_id>`::
43-
(Optional, string) Identifier for the {anomaly-job}. It can be a job
44-
identifier, a group name, or a wildcard expression. If you do not specify one
45-
of these options, the API returns information for all {anomaly-jobs}.
43+
(Optional, string)
44+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-default]
4645

4746
[[ml-get-job-query-parms]]
4847
==== {api-query-parms-title}
4948

5049
`allow_no_jobs`::
51-
(Optional, boolean) Specifies what to do when the request:
50+
(Optional, boolean)
51+
include::{docdir}/ml/ml-shared.asciidoc[tag=allow-no-jobs]
52+
53+
54+
[[ml-get-job-results]]
55+
==== {api-response-body-title}
56+
57+
The API returns an array of {anomaly-job} resources, which have the following
58+
properties:
59+
60+
`allow_lazy_open`::
61+
(boolean)
62+
include::{docdir}/ml/ml-shared.asciidoc[tag=allow-lazy-open]
63+
64+
[[get-analysisconfig]]`analysis_config`::
65+
(object)
66+
include::{docdir}/ml/ml-shared.asciidoc[tag=analysis-config]
67+
68+
[[get-analysislimits]]`analysis_limits`::
69+
(object)
70+
include::{docdir}/ml/ml-shared.asciidoc[tag=analysis-limits]
71+
72+
`background_persist_interval`::
73+
(time units)
74+
include::{docdir}/ml/ml-shared.asciidoc[tag=background-persist-interval]
75+
76+
`create_time`::
77+
(string) The time the job was created. For example, `1491007356077`. This
78+
property is informational; you cannot change its value.
79+
80+
[[get-customsettings]]`custom_settings`::
81+
(object)
82+
include::{docdir}/ml/ml-shared.asciidoc[tag=custom-settings]
83+
84+
[[get-datadescription]]`data_description`::
85+
(object)
86+
include::{docdir}/ml/ml-shared.asciidoc[tag=data-description]
87+
88+
`description`::
89+
(string) An optional description of the job.
90+
91+
`finished_time`::
92+
(string) If the job closed or failed, this is the time the job finished,
93+
otherwise it is `null`. This property is informational; you cannot change its
94+
value.
95+
96+
`groups`::
97+
(array of strings)
98+
include::{docdir}/ml/ml-shared.asciidoc[tag=groups]
99+
100+
`job_id`::
101+
(string)
102+
include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-define]
52103
+
53104
--
54-
* Contains wildcard expressions and there are no jobs that match.
55-
* Contains the `_all` string or no identifiers and there are no matches.
56-
* Contains wildcard expressions and there are only partial matches.
57-
58-
The default value is `true`, which returns an empty `jobs` array
59-
when there are no matches and the subset of results when there are partial
60-
matches. If this parameter is `false`, the request returns a `404` status code
61-
when there are no matches or only partial matches.
105+
This property is informational; you cannot change the identifier for existing
106+
jobs.
62107
--
63108

64-
[[ml-get-job-results]]
65-
==== {api-response-body-title}
109+
`job_type`::
110+
(string) Reserved for future use, currently set to `anomaly_detector`.
66111

67-
The API returns the following information:
112+
`job_version`::
113+
(string) The version of {es} that existed on the node when the job was created.
68114

69-
`jobs`::
70-
(array) An array of {anomaly-job} resources.
71-
For more information, see <<ml-job-resource>>.
115+
[[get-modelplotconfig]]`model_plot_config`::
116+
(object)
117+
include::{docdir}/ml/ml-shared.asciidoc[tag=model-plot-config]
118+
119+
`model_snapshot_id`::
120+
(string)
121+
include::{docdir}/ml/ml-shared.asciidoc[tag=model-snapshot-id]
122+
+
123+
--
124+
This property is informational; you cannot change its value.
125+
--
126+
127+
`model_snapshot_retention_days`::
128+
(long)
129+
include::{docdir}/ml/ml-shared.asciidoc[tag=model-snapshot-retention-days]
130+
131+
`renormalization_window_days`::
132+
(long)
133+
include::{docdir}/ml/ml-shared.asciidoc[tag=renormalization-window-days]
134+
135+
`results_index_name`::
136+
(string)
137+
include::{docdir}/ml/ml-shared.asciidoc[tag=results-index-name]
72138

73139
[[ml-get-job-response-codes]]
74140
==== {api-response-codes-title}
@@ -80,53 +146,68 @@ The API returns the following information:
80146
[[ml-get-job-example]]
81147
==== {api-examples-title}
82148

83-
The following example gets configuration information for the `total-requests` job:
149+
//The following example gets configuration information for the `total-requests` job:
84150

85151
[source,console]
86152
--------------------------------------------------
87-
GET _ml/anomaly_detectors/total-requests
153+
GET _ml/anomaly_detectors/high_sum_total_sales
88154
--------------------------------------------------
89-
// TEST[skip:setup:server_metrics_job]
155+
// TEST[skip:Kibana sample data]
90156

91157
The API returns the following results:
92158

93-
[source,console-result]
159+
[source,js]
94160
----
95161
{
96162
"count": 1,
97163
"jobs": [
98164
{
99-
"job_id": "total-requests",
100-
"job_type": "anomaly_detector",
101-
"job_version": "7.0.0-alpha1",
102-
"description": "Total sum of requests",
103-
"create_time": 1517011406091,
104-
"analysis_config": {
105-
"bucket_span": "10m",
106-
"detectors": [
165+
"job_id" : "high_sum_total_sales",
166+
"job_type" : "anomaly_detector",
167+
"job_version" : "8.0.0",
168+
"groups" : [
169+
"kibana_sample_data",
170+
"kibana_sample_ecommerce"
171+
],
172+
"description" : "Find customers spending an unusually high amount in an hour",
173+
"create_time" : 1575402224732,
174+
"finished_time" : 1575402238311,
175+
"analysis_config" : {
176+
"bucket_span" : "1h",
177+
"detectors" : [
107178
{
108-
"detector_description": "Sum of total",
109-
"function": "sum",
110-
"field_name": "total",
111-
"detector_index": 0
179+
"detector_description" : "High total sales",
180+
"function" : "high_sum",
181+
"field_name" : "taxful_total_price",
182+
"over_field_name" : "customer_full_name.keyword",
183+
"detector_index" : 0
112184
}
113185
],
114-
"influencers": [ ]
186+
"influencers" : [
187+
"customer_full_name.keyword",
188+
"category.keyword"
189+
]
190+
},
191+
"analysis_limits" : {
192+
"model_memory_limit" : "10mb",
193+
"categorization_examples_limit" : 4
194+
},
195+
"data_description" : {
196+
"time_field" : "order_date",
197+
"time_format" : "epoch_ms"
115198
},
116-
"analysis_limits": {
117-
"model_memory_limit": "1024mb",
118-
"categorization_examples_limit": 4
199+
"model_plot_config" : {
200+
"enabled" : true
119201
},
120-
"data_description": {
121-
"time_field": "timestamp",
122-
"time_format": "epoch_ms"
202+
"model_snapshot_retention_days" : 1,
203+
"custom_settings" : {
204+
"created_by" : "ml-module-sample",
205+
...
123206
},
124-
"model_snapshot_retention_days": 1,
125-
"results_index_name": "shared",
126-
"allow_lazy_open": false
207+
"model_snapshot_id" : "1575402237",
208+
"results_index_name" : "shared",
209+
"allow_lazy_open" : false
127210
}
128211
]
129212
}
130213
----
131-
// TESTRESPONSE[s/"7.0.0-alpha1"/$body.$_path/]
132-
// TESTRESPONSE[s/1517011406091/$body.$_path/]

0 commit comments

Comments
 (0)