2017-06-19 21:23:58 -04:00
|
|
|
[role="xpack"]
|
2018-08-31 19:49:24 -04:00
|
|
|
[testenv="platinum"]
|
2017-04-04 18:26:39 -04:00
|
|
|
[[ml-put-datafeed]]
|
2018-12-20 13:23:28 -05:00
|
|
|
=== Create {dfeeds} API
|
2019-04-30 13:46:13 -04:00
|
|
|
|
|
|
|
[subs="attributes"]
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2018-12-20 13:23:28 -05:00
|
|
|
<titleabbrev>Create {dfeeds}</titleabbrev>
|
2017-12-14 13:52:49 -05:00
|
|
|
++++
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-06-13 16:37:35 -04:00
|
|
|
Instantiates a {dfeed}.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-put-datafeed-request]]
|
|
|
|
==== {api-request-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2018-12-07 15:34:11 -05:00
|
|
|
`PUT _ml/datafeeds/<feed_id>`
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
[[ml-put-datafeed-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
2019-07-26 13:47:03 -04:00
|
|
|
* You must create an {anomaly-job} before you create a {dfeed}.
|
2019-06-27 16:58:42 -04:00
|
|
|
* If {es} {security-features} are enabled, you must have `manage_ml` or `manage`
|
|
|
|
cluster privileges to use this API. See
|
|
|
|
{stack-ov}/security-privileges.html[Security privileges].
|
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-put-datafeed-desc]]
|
|
|
|
==== {api-description-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-26 13:47:03 -04:00
|
|
|
You can associate only one {dfeed} to each {anomaly-job}.
|
2017-04-10 11:59:27 -04:00
|
|
|
|
2019-06-27 16:58:42 -04:00
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
* You must use {kib} or this API to create a {dfeed}. Do not put a
|
|
|
|
{dfeed} directly to the `.ml-config` index using the {es} index API. If {es}
|
|
|
|
{security-features} are enabled, do not give users `write` privileges on the
|
|
|
|
`.ml-config` index.
|
|
|
|
* When {es} {security-features} are enabled, your {dfeed} remembers which roles
|
|
|
|
the user who created it had at the time of creation and runs the query using
|
|
|
|
those same roles.
|
|
|
|
====
|
2019-02-08 06:35:37 -05:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-put-datafeed-path-parms]]
|
|
|
|
==== {api-path-parms-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`<feed_id>`::
|
|
|
|
(Required, string) A numerical character string that uniquely identifies the
|
|
|
|
{dfeed}. This identifier can contain lowercase alphanumeric characters (a-z
|
|
|
|
and 0-9), hyphens, and underscores. It must start and end with alphanumeric
|
|
|
|
characters.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-put-datafeed-request-body]]
|
|
|
|
==== {api-request-body-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-07-12 11:26:31 -04:00
|
|
|
`aggregations`::
|
|
|
|
(Optional, object) If set, the {dfeed} performs aggregation searches. For more
|
|
|
|
information, see <<ml-datafeed-resource>>.
|
|
|
|
|
|
|
|
`chunking_config`::
|
|
|
|
(Optional, object) Specifies how data searches are split into time chunks. See
|
|
|
|
<<ml-datafeed-chunking-config>>.
|
|
|
|
|
|
|
|
`delayed_data_check_config`::
|
|
|
|
(Optional, object) Specifies whether the data feed checks for missing data and
|
|
|
|
the size of the window. See <<ml-datafeed-delayed-data-check-config>>.
|
|
|
|
|
|
|
|
`frequency`::
|
2019-08-08 07:43:55 -04:00
|
|
|
(Optional, <<time-units, time units>>) The interval at which scheduled queries
|
|
|
|
are made while the {dfeed} runs in real time. The default value is either the
|
|
|
|
bucket span for short bucket spans, or, for longer bucket spans, a sensible
|
|
|
|
fraction of the bucket span. For example: `150s`.
|
2019-07-12 11:26:31 -04:00
|
|
|
|
|
|
|
`indices`::
|
|
|
|
(Required, array) An array of index names. Wildcards are supported. For
|
|
|
|
example: `["it_ops_metrics", "server*"]`.
|
2019-08-30 10:27:07 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
NOTE: If any indices are in remote clusters then `cluster.remote.connect` must
|
|
|
|
not be set to `false` on any ML node.
|
|
|
|
--
|
2019-07-12 11:26:31 -04:00
|
|
|
|
|
|
|
`job_id`::
|
|
|
|
(Required, string) A numerical character string that uniquely identifies the
|
2019-07-26 13:47:03 -04:00
|
|
|
{anomaly-job}.
|
2019-07-12 11:26:31 -04:00
|
|
|
|
|
|
|
`query`::
|
|
|
|
(Optional, object) The {es} query domain-specific language (DSL). This value
|
|
|
|
corresponds to the query object in an {es} search POST body. All the options
|
|
|
|
that are supported by {Es} can be used, as this object is passed verbatim to
|
|
|
|
{es}. By default, this property has the following value:
|
|
|
|
`{"match_all": {"boost": 1}}`.
|
|
|
|
|
|
|
|
`query_delay`::
|
2019-08-08 07:43:55 -04:00
|
|
|
(Optional, <<time-units, time units>>) The number of seconds behind real time
|
|
|
|
that data is queried. For example, if data from 10:04 a.m. might not be
|
|
|
|
searchable in {es} until 10:06 a.m., set this property to 120 seconds. The
|
|
|
|
default value is `60s`.
|
2019-07-12 11:26:31 -04:00
|
|
|
|
|
|
|
`script_fields`::
|
|
|
|
(Optional, object) Specifies scripts that evaluate custom expressions and
|
|
|
|
returns script fields to the {dfeed}. The
|
|
|
|
<<ml-detectorconfig,detector configuration objects>> in a job can contain
|
|
|
|
functions that use these script fields. For more information, see
|
2019-07-19 09:16:35 -04:00
|
|
|
<<request-body-search-script-fields,Script fields>>.
|
2019-07-12 11:26:31 -04:00
|
|
|
|
|
|
|
`scroll_size`::
|
|
|
|
(Optional, unsigned integer) The `size` parameter that is used in {es}
|
|
|
|
searches. The default value is `1000`.
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-04-10 11:59:27 -04:00
|
|
|
For more information about these properties,
|
2017-05-02 15:45:42 -04:00
|
|
|
see <<ml-datafeed-resource>>.
|
2017-04-10 11:59:27 -04:00
|
|
|
|
2019-06-27 12:42:47 -04:00
|
|
|
[[ml-put-datafeed-example]]
|
|
|
|
==== {api-examples-title}
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-10-30 10:54:33 -04:00
|
|
|
The following example creates the `datafeed-total-requests` {dfeed}:
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2017-04-04 18:26:39 -04:00
|
|
|
--------------------------------------------------
|
2018-12-07 15:34:11 -05:00
|
|
|
PUT _ml/datafeeds/datafeed-total-requests
|
2017-04-04 18:26:39 -04:00
|
|
|
{
|
2017-10-30 10:54:33 -04:00
|
|
|
"job_id": "total-requests",
|
2018-03-07 16:53:49 -05:00
|
|
|
"indices": ["server-metrics"]
|
2017-04-04 18:26:39 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2018-08-31 19:49:24 -04:00
|
|
|
// TEST[skip:setup:server_metrics_job]
|
2017-04-04 18:26:39 -04:00
|
|
|
|
2017-05-02 15:45:42 -04:00
|
|
|
When the {dfeed} is created, you receive the following results:
|
2019-09-06 16:09:09 -04:00
|
|
|
|
|
|
|
[source,console-result]
|
2017-04-04 18:26:39 -04:00
|
|
|
----
|
|
|
|
{
|
2017-10-30 10:54:33 -04:00
|
|
|
"datafeed_id": "datafeed-total-requests",
|
|
|
|
"job_id": "total-requests",
|
|
|
|
"query_delay": "83474ms",
|
2017-05-04 06:37:12 -04:00
|
|
|
"indices": [
|
2017-10-30 10:54:33 -04:00
|
|
|
"server-metrics"
|
2017-04-10 11:59:27 -04:00
|
|
|
],
|
|
|
|
"query": {
|
|
|
|
"match_all": {
|
2017-10-30 10:54:33 -04:00
|
|
|
"boost": 1.0
|
2017-04-10 11:59:27 -04:00
|
|
|
}
|
2017-04-04 18:26:39 -04:00
|
|
|
},
|
2017-04-11 21:52:47 -04:00
|
|
|
"scroll_size": 1000,
|
|
|
|
"chunking_config": {
|
|
|
|
"mode": "auto"
|
|
|
|
}
|
2017-04-04 18:26:39 -04:00
|
|
|
}
|
|
|
|
----
|
2018-02-09 12:16:24 -05:00
|
|
|
// TESTRESPONSE[s/"query_delay": "83474ms"/"query_delay": $body.query_delay/]
|
2018-12-07 15:34:11 -05:00
|
|
|
// TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]
|