OpenSearch/docs/reference/ml/apis/update-datafeed.asciidoc

135 lines
3.6 KiB
Plaintext

[role="xpack"]
[testenv="platinum"]
[[ml-update-datafeed]]
=== Update {dfeeds} API
[subs="attributes"]
++++
<titleabbrev>Update {dfeeds}</titleabbrev>
++++
Updates certain properties of a {dfeed}.
==== Request
`POST _ml/datafeeds/<feed_id>/_update`
//===== Description
==== Path Parameters
`feed_id` (required)::
(string) Identifier for the {dfeed}
==== Request Body
The following properties can be updated after the {dfeed} is created:
`aggregations`::
(object) If set, the {dfeed} performs aggregation searches.
For more information, see <<ml-datafeed-resource>>.
`chunking_config`::
(object) Specifies how data searches are split into time chunks.
See <<ml-datafeed-chunking-config>>.
`frequency`::
(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`.
`indices`::
(array) An array of index names. Wildcards are supported. For example:
`["it_ops_metrics", "server*"]`.
`job_id`::
(string) A numerical character string that uniquely identifies the job.
`query`::
(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`::
(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`.
`script_fields`::
(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 {ref}/search-request-script-fields.html[Script Fields].
`scroll_size`::
(unsigned integer) The `size` parameter that is used in {es} searches.
The default value is `1000`.
For more information about these properties,
see <<ml-datafeed-resource>>.
==== Authorization
If {es} {security-features} are enabled, you must have `manage_ml`, or `manage`
cluster privileges to use this API. For more information, see
{stack-ov}/security-privileges.html[Security Privileges].
==== Security Integration
When {es} {security-features} are enabled, your {dfeed} remembers which roles the
user who updated it had at the time of update and runs the query using those
same roles.
==== Examples
The following example updates the query for the `datafeed-total-requests`
{dfeed} so that only log entries of error level are analyzed:
[source,js]
--------------------------------------------------
POST _ml/datafeeds/datafeed-total-requests/_update
{
"query": {
"term": {
"level": "error"
}
}
}
--------------------------------------------------
// CONSOLE
// TEST[skip:setup:server_metrics_datafeed]
When the {dfeed} is updated, you receive the full {dfeed} configuration with
with the updated values:
[source,js]
----
{
"datafeed_id": "datafeed-total-requests",
"job_id": "total-requests",
"query_delay": "83474ms",
"indices": ["server-metrics"],
"query": {
"term": {
"level": {
"value": "error",
"boost": 1.0
}
}
},
"scroll_size": 1000,
"chunking_config": {
"mode": "auto"
}
}
----
// TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]