2018-10-05 11:45:46 -04:00
|
|
|
--
|
|
|
|
:api: put-job
|
|
|
|
:request: PutJobRequest
|
|
|
|
:response: PutJobResponse
|
|
|
|
--
|
2019-09-10 11:26:56 -04:00
|
|
|
[role="xpack"]
|
2018-10-05 11:45:46 -04:00
|
|
|
[id="{upid}-{api}"]
|
2019-07-25 11:58:16 -04:00
|
|
|
=== Put {anomaly-job} API
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2019-07-25 11:58:16 -04:00
|
|
|
Creates a new {anomaly-job} in the cluster. The API accepts a +{request}+ object
|
2018-10-05 11:45:46 -04:00
|
|
|
as a request and returns a +{response}+.
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
[id="{upid}-{api}-request"]
|
2019-07-25 11:58:16 -04:00
|
|
|
==== Put {anomaly-job} request
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
A +{request}+ requires the following argument:
|
2018-08-14 14:52:54 -04:00
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-10-05 11:45:46 -04:00
|
|
|
include-tagged::{doc-tests-file}[{api}-request]
|
2018-08-14 14:52:54 -04:00
|
|
|
--------------------------------------------------
|
2019-07-25 11:58:16 -04:00
|
|
|
<1> The configuration of the {anomaly-job} to create as a `Job`
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
[id="{upid}-{api}-config"]
|
2019-07-25 11:58:16 -04:00
|
|
|
==== Job configuration
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2019-07-25 11:58:16 -04:00
|
|
|
The `Job` object contains all the details about the {anomaly-job}
|
2018-08-14 14:52:54 -04:00
|
|
|
configuration.
|
|
|
|
|
|
|
|
A `Job` requires the following arguments:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-10-05 11:45:46 -04:00
|
|
|
include-tagged::{doc-tests-file}[{api}-config]
|
2018-08-14 14:52:54 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The job ID
|
|
|
|
<2> An analysis configuration
|
|
|
|
<3> A data description
|
|
|
|
<4> Optionally, a human-readable description
|
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
[id="{upid}-{api}-analysis-config"]
|
2019-07-25 11:58:16 -04:00
|
|
|
==== Analysis configuration
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2019-07-25 11:58:16 -04:00
|
|
|
The analysis configuration of the {anomaly-job} is defined in the `AnalysisConfig`.
|
2018-08-14 14:52:54 -04:00
|
|
|
`AnalysisConfig` reflects all the configuration
|
|
|
|
settings that can be defined using the REST API.
|
|
|
|
|
|
|
|
Using the REST API, we could define this analysis configuration:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
"analysis_config" : {
|
|
|
|
"bucket_span" : "10m",
|
|
|
|
"detectors" : [
|
|
|
|
{
|
|
|
|
"detector_description" : "Sum of total",
|
|
|
|
"function" : "sum",
|
|
|
|
"field_name" : "total"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// NOTCONSOLE
|
|
|
|
|
|
|
|
Using the `AnalysisConfig` object and the high level REST client, the list
|
|
|
|
of detectors must be built first.
|
|
|
|
|
|
|
|
An example of building a `Detector` instance is as follows:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-10-05 11:45:46 -04:00
|
|
|
include-tagged::{doc-tests-file}[{api}-detector]
|
2018-08-14 14:52:54 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The function to use
|
|
|
|
<2> The field to apply the function to
|
|
|
|
<3> Optionally, a human-readable description
|
|
|
|
|
|
|
|
Then the same configuration would be:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-10-05 11:45:46 -04:00
|
|
|
include-tagged::{doc-tests-file}[{api}-analysis-config]
|
2018-08-14 14:52:54 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Create a list of detectors
|
|
|
|
<2> Pass the list of detectors to the analysis config builder constructor
|
|
|
|
<3> The bucket span
|
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
[id="{upid}-{api}-data-description"]
|
2019-07-25 11:58:16 -04:00
|
|
|
==== Data description
|
2018-08-14 14:52:54 -04:00
|
|
|
|
|
|
|
After defining the analysis config, the next thing to define is the
|
|
|
|
data description, using a `DataDescription` instance. `DataDescription`
|
|
|
|
reflects all the configuration settings that can be defined using the
|
|
|
|
REST API.
|
|
|
|
|
|
|
|
Using the REST API, we could define this metrics configuration:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
"data_description" : {
|
|
|
|
"time_field" : "timestamp"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// NOTCONSOLE
|
|
|
|
|
|
|
|
Using the `DataDescription` object and the high level REST client, the same
|
|
|
|
configuration would be:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-10-05 11:45:46 -04:00
|
|
|
include-tagged::{doc-tests-file}[{api}-data-description]
|
2018-08-14 14:52:54 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The time field
|
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
include::../execution.asciidoc[]
|
2018-08-14 14:52:54 -04:00
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
[id="{upid}-{api}-response"]
|
2018-08-14 14:52:54 -04:00
|
|
|
==== Response
|
|
|
|
|
2018-10-05 11:45:46 -04:00
|
|
|
The returned +{response}+ returns the full representation of
|
2018-08-14 14:52:54 -04:00
|
|
|
the new {ml} job if it has been successfully created. This will
|
|
|
|
contain the creation time and other fields initialized using
|
|
|
|
default values:
|
|
|
|
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
|
|
--------------------------------------------------
|
2018-10-05 11:45:46 -04:00
|
|
|
include-tagged::{doc-tests-file}[{api}-response]
|
2018-08-14 14:52:54 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> The creation time is a field that was not passed in the `Job` object in the request
|