Create a datafeed
- PUT /_ml/datafeeds/{datafeed_id}
Datafeeds retrieve data from Elasticsearch for analysis by an anomaly detection job.
You can associate only one datafeed with each anomaly detection job.
The datafeed contains a query that runs at a defined interval (frequency).
If you are concerned about delayed data, you can add a delay (query_delay') at each interval. By default, the datafeed uses the following query: {"match_all": {"boost": 1}}`.
When Elasticsearch security features are enabled, your datafeed remembers which roles the user who created it had
at the time of creation and runs the query using those same roles. If you provide secondary authorization headers,
those credentials are used instead.
You must use Kibana, this API, or the create anomaly detection jobs API to create a datafeed. Do not add a datafeed
directly to the .ml-config index. Do not give users write privileges on the .ml-config index.
Required authorization
- Index privileges read
- Cluster privileges manage_ml
Query parameters
-
allow_no_indicesboolean · default: true -
A setting that does two separate checks on the index expression. If
false, the request returns an error (1) if any wildcard expression (including_alland*) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. Iftrue, index expressions that resolve to no indices are allowed and the request returns an empty result. -
expand_wildcardsstring · default: open -
Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values.
Supported values include:
all: Match any data stream or index, including hidden ones.open: Match open, non-hidden indices. Also matches any non-hidden data stream.closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden: Match hidden data streams and hidden indices. Must be combined withopen,closed, orboth.none: Wildcard expressions are not accepted.
-
Values:
allopenclosedhiddennone -
ignore_throttledboolean · default: truedeprecated -
If true, concrete, expanded, or aliased indices are ignored when frozen.
-
If
false, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. Iftrue, unavailable concrete targets are silently ignored.
Request body
-
aggregationsmap string to Aggregation -
If set, the datafeed performs aggregation searches. Support for aggregations is limited and should be used only with low cardinality data.
-
chunking_configobject -
Datafeeds might be required to search over long time periods, for several months or years. This search is split into time chunks in order to ensure the load on Elasticsearch is managed. Chunking configuration controls how the size of these time chunks are calculated; it is an advanced configuration option.
-
moderequired -
If the mode is
auto, the chunk size is dynamically calculated; this is the recommended value when the datafeed does not use aggregations. If the mode ismanual, chunking is applied according to the specifiedtime_span; use this mode when the datafeed uses aggregations. If the mode isoff, no chunking is applied. -
Values:
automanualoff -
delayed_data_check_configobject -
Specifies whether the datafeed checks for missing data and the size of the window. The datafeed can optionally search over indices that have already been read in an effort to determine whether any data has subsequently been added to the index. If missing data is found, it is a good indication that the
query_delayis set too low and the data is being indexed after the datafeed has passed that moment in time. This check runs only on real-time datafeeds. -
check_windowstring -
The window of time that is searched for late data. This window of time ends with the latest finalized bucket. It defaults to null, which causes an appropriate
check_windowto be calculated when the real-time datafeed runs. In particular, the defaultcheck_windowspan calculation is based on the maximum of2hor8 * bucket_span. -
frequencystring -
The interval at which scheduled queries are made while the datafeed 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. When
frequencyis shorter than the bucket span, interim results for the last (partial) bucket are written then eventually overwritten by the full bucket results. If the datafeed uses aggregations, this value must be divisible by the interval of the date histogram aggregation. -
indicesstring -
An array of index names. Wildcards are supported. If any of the indices are in remote clusters, the master nodes and the machine learning nodes must have the
remote_cluster_clientrole. -
indices_optionsobject -
Specifies index expansion options that are used during search
-
allow_no_indicesboolean -
A setting that does two separate checks on the index expression. If
false, the request returns an error (1) if any wildcard expression (including_alland*) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. Iftrue, index expressions that resolve to no indices are allowed and the request returns an empty result. -
expand_wildcardsstring -
Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as
open,hidden.Supported values include:
all: Match any data stream or index, including hidden ones.open: Match open, non-hidden indices. Also matches any non-hidden data stream.closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden: Match hidden data streams and hidden indices. Must be combined withopen,closed, orboth.none: Wildcard expressions are not accepted.
-
Values:
allopenclosedhiddennone -
If
false, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. Iftrue, unavailable concrete targets are silently ignored. -
max_empty_searchesnumber -
If a real-time datafeed has never seen any data (including during any initial training period), it automatically stops and closes the associated job after this many real-time searches return no documents. In other words, it stops after
frequencytimesmax_empty_searchesof real-time operation. If not set, a datafeed with no end time that sees no data remains started until it is explicitly stopped. By default, it is not set. -
max_consecutive_extraction_failuresnumber -
The maximum number of consecutive real-time data extraction failures the datafeed tolerates before it automatically stops itself, leaving the associated job open. The consecutive-failure counter resets on any cycle that extracts successfully, including empty-data cycles. If not set, the threshold defaults to roughly one day's worth of searches based on the datafeed
frequency(floored at 1). Set to-1to disable auto-stop and retry indefinitely. Values of0or less than-1are rejected. -
queryQuery · default: {"match_all": {"boost": 1}} -
The Elasticsearch query domain-specific language (DSL). This value corresponds to the query object in an Elasticsearch search POST body. All the options that are supported by Elasticsearch can be used, as this object is passed verbatim to Elasticsearch.
-
query_delaystring -
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 Elasticsearch until 10:06 a.m., set this property to 120 seconds. The default value is randomly selected between
60sand120s. This randomness improves the query performance when there are multiple jobs running on the same node. -
script_fieldsmap string to object -
Specifies scripts that evaluate custom expressions and returns script fields to the datafeed. The detector configuration objects in a job can contain functions that use these script fields.
Response
-
aggregationsmap string to Aggregation -
If an API key was used for the most recent update to the datafeed, its name and identifier are listed in the response.
-
The identifier for the API key.
-
The name of the API key.
-
If a user ID was used for the most recent update to the datafeed, its roles at the time of the update are listed in the response.
-
If a service account was used for the most recent update to the datafeed, the account name is listed in the response.
-
chunking_configobjectrequired -
moderequired -
If the mode is
auto, the chunk size is dynamically calculated; this is the recommended value when the datafeed does not use aggregations. If the mode ismanual, chunking is applied according to the specifiedtime_span; use this mode when the datafeed uses aggregations. If the mode isoff, no chunking is applied. -
Values:
automanualoff -
delayed_data_check_configobject -
check_windowstring -
The window of time that is searched for late data. This window of time ends with the latest finalized bucket. It defaults to null, which causes an appropriate
check_windowto be calculated when the real-time datafeed runs. In particular, the defaultcheck_windowspan calculation is based on the maximum of2hor8 * bucket_span. -
indices_optionsobject -
allow_no_indicesboolean -
A setting that does two separate checks on the index expression. If
false, the request returns an error (1) if any wildcard expression (including_alland*) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. Iftrue, index expressions that resolve to no indices are allowed and the request returns an empty result. -
expand_wildcardsstring -
Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as
open,hidden.Supported values include:
all: Match any data stream or index, including hidden ones.open: Match open, non-hidden indices. Also matches any non-hidden data stream.closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.hidden: Match hidden data streams and hidden indices. Must be combined withopen,closed, orboth.none: Wildcard expressions are not accepted.
-
Values:
allopenclosedhiddennone -
If
false, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. Iftrue, unavailable concrete targets are silently ignored. -
queryQueryrequired