原文地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/ml-update-job.html, 原文档版权归 www.elastic.co 所有

Update anomaly detection jobs APIedit

Updates certain properties of an anomaly detection job.

Requestedit

POST _ml/anomaly_detectors/<job_id>/_update

Prerequisitesedit

  • If the Elasticsearch security features are enabled, you must have manage_ml or manage cluster privileges to use this API. See Security privileges.

Path parametersedit

<job_id>
(Required, string) Identifier for the anomaly detection job.

Request bodyedit

The following properties can be updated after the job is created:

allow_lazy_open

(boolean) Advanced configuration option. Specifies whether this job can open when there is insufficient machine learning node capacity for it to be immediately assigned to a node. The default value is false; if a machine learning node with capacity to run the job cannot immediately be found, the open anomaly detection jobs API returns an error. However, this is also subject to the cluster-wide xpack.ml.max_lazy_ml_nodes setting; see Advanced machine learning settings. If this option is set to true, the open anomaly detection jobs API does not return an error and the job waits in the opening state until sufficient machine learning node capacity is available.

If the job is open when you make the update, you must stop the datafeed, close the job, then reopen the job and restart the datafeed for the changes to take effect.

analysis_limits

(Optional, object) Limits can be applied for the resources required to hold the mathematical models in memory. These limits are approximate and can be set per job. They do not control the memory used by other processes, for example the Elasticsearch Java processes.

Properties of analysis_limits
model_memory_limit

(long or string) The approximate maximum amount of memory resources that are required for analytical processing. Once this limit is approached, data pruning becomes more aggressive. Upon exceeding this limit, new entities are not modeled. The default value for jobs created in version 6.1 and later is 1024mb. This value will need to be increased for jobs that are expected to analyze high cardinality fields, but the default is set to a relatively small size to ensure that high resource usage is a conscious decision. The default value for jobs created in versions earlier than 6.1 is 4096mb.

If you specify a number instead of a string, the units are assumed to be MiB. Specifying a string is recommended for clarity. If you specify a byte size unit of b or kb and the number does not equate to a discrete number of megabytes, it is rounded down to the closest MiB. The minimum valid value is 1 MiB. If you specify a value less than 1 MiB, an error occurs. For more information about supported byte size units, see Byte size units.

If your elasticsearch.yml file contains an xpack.ml.max_model_memory_limit setting, an error occurs when you try to create jobs that have model_memory_limit values greater than that setting. For more information, see Machine learning settings.

You can update the analysis_limits only while the job is closed. The model_memory_limit property value cannot be decreased below the current usage.

If the memory_status property in the model_size_stats object has a value of hard_limit,mthis means that it was unable to process some data. You might want to re-run the job with an increased model_memory_limit.

background_persist_interval

(time units) Advanced configuration option. The time between each periodic persistence of the model. The default value is a randomized value between 3 to 4 hours, which avoids all jobs persisting at exactly the same time. The smallest allowed value is 1 hour.

For very large models (several GB), persistence could take 10-20 minutes, so do not set the background_persist_interval value too low.

If the job is open when you make the update, you must stop the datafeed, close the job, then reopen the job and restart the datafeed for the changes to take effect.

custom_settings
(object) Advanced configuration option. Contains custom meta data about the job. For example, it can contain custom URL information as shown in Adding custom URLs to machine learning results.
description
(string) A description of the job.
detectors

(array) An array of detector update objects.

Properties of detectors
custom_rules

(array) An array of custom rule objects, which enable you to customize the way detectors operate. For example, a rule may dictate to the detector conditions under which results should be skipped. For more examples, see Customizing detectors with custom rules.

Properties of custom_rules
actions

(array) The set of actions to be triggered when the rule applies. If more than one action is specified the effects of all actions are combined. The available actions include:

  • skip_result: The result will not be created. This is the default value. Unless you also specify skip_model_update, the model will be updated as usual with the corresponding series value.
  • skip_model_update: The value for that series will not be used to update the model. Unless you also specify skip_result, the results will be created as usual. This action is suitable when certain values are expected to be consistently anomalous and they affect the model in a way that negatively impacts the rest of the results.
conditions

(array) An optional array of numeric conditions when the rule applies. A rule must either have a non-empty scope or at least one condition. Multiple conditions are combined together with a logical AND. A condition has the following properties:

Properties of conditions
applies_to
(string) Specifies the result property to which the condition applies. The available options are actual, typical, diff_from_typical, time. If your detector uses lat_long, metric, rare, or freq_rare functions, you can only specify conditions that apply to time.
operator
(string) Specifies the condition operator. The available options are gt (greater than), gte (greater than or equals), lt (less than) and lte (less than or equals).
value
(double) The value that is compared against the applies_to field using the operator.
scope

(object) An optional scope of series where the rule applies. A rule must either have a non-empty scope or at least one condition. By default, the scope includes all series. Scoping is allowed for any of the fields that are also specified in by_field_name, over_field_name, or partition_field_name. To add a scope for a field, add the field name as a key in the scope object and set its value to an object with the following properties:

Properties of scope
filter_id
(string) The id of the filter to be used.
filter_type
(string) Either include (the rule applies for values in the filter) or exclude (the rule applies for values not in the filter). Defaults to include.
description
(string) A description of the detector. For example, Low event rate.
detector_index

(integer) A unique identifier for the detector. This identifier is based on the order of the detectors in the analysis_config, starting at zero.

If you want to update a specific detector, you must use this identifier. You cannot, however, change the detector_index value for a detector.

groups
(array of strings) A list of job groups. A job can belong to no groups or many.
model_plot_config

(object) This advanced configuration option stores model information along with the results. It provides a more detailed view into anomaly detection.

If you enable model plot it can add considerable overhead to the performance of the system; it is not feasible for jobs with many entities.

Model plot provides a simplified and indicative view of the model and its bounds. It does not display complex features such as multivariate correlations or multimodal data. As such, anomalies may occasionally be reported which cannot be seen in the model plot.

Model plot config can be configured when the job is created or updated later. It must be disabled if performance issues are experienced.

Properties of model_plot_config
enabled
(boolean) If true, enables calculation and storage of the model bounds for each entity that is being analyzed. By default, this is not enabled.
model_snapshot_retention_days
(long) Advanced configuration option. The period of time (in days) that model snapshots are retained. Age is calculated relative to the timestamp of the newest model snapshot. The default value is 1, which means snapshots that are one day (twenty-four hours) older than the newest snapshot are deleted.
renormalization_window_days

(long) Advanced configuration option. The period over which adjustments to the score are applied, as new data is seen. The default value is the longer of 30 days or 100 bucket_spans.

If the job is open when you make the update, you must stop the datafeed, close the job, then reopen the job and restart the datafeed for the changes to take effect.

results_retention_days
(long) Advanced configuration option. The period of time (in days) that results are retained. Age is calculated relative to the timestamp of the latest bucket result. If this property has a non-null value, once per day at 00:30 (server time), results that are the specified number of days older than the latest bucket result are deleted from Elasticsearch. The default value is null, which means all results are retained.

Examplesedit

POST _ml/anomaly_detectors/low_request_rate/_update
{
  "description":"An updated job",
  "detectors": {
    "detector_index": 0,
    "description": "An updated detector description"
  },
  "groups": ["kibana_sample_data","kibana_sample_web_logs"],
  "model_plot_config": {
    "enabled": true
  },
  "renormalization_window_days": 30,
  "background_persist_interval": "2h",
  "model_snapshot_retention_days": 7,
  "results_retention_days": 60
}

When the anomaly detection job is updated, you receive a summary of the job configuration information, including the updated property values. For example:

{
  "job_id" : "low_request_rate",
  "job_type" : "anomaly_detector",
  "job_version" : "7.5.1",
  "groups" : [
    "kibana_sample_data",
    "kibana_sample_web_logs"
  ],
  "description" : "An updated job",
  "create_time" : 1578101716125,
  "finished_time" : 1578101721816,
  "analysis_config" : {
    "bucket_span" : "1h",
    "summary_count_field_name" : "doc_count",
    "detectors" : [
      {
        "detector_description" : "An updated detector description",
        "function" : "low_count",
        "detector_index" : 0
      }
    ],
    "influencers" : [ ]
  },
  ...
}