elasticsearch/docs/reference/ml/anomaly-detection/apis/revert-snapshot.asciidoc
Liam Thompson 33a71e3289
[DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413)
* Remove `es-test-dir` book-scoped variable

* Remove `plugins-examples-dir` book-scoped variable

* Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables

- In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed.
- In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path
- In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem

* Replace `es-repo-dir` with `es-ref-dir`

* Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
2024-04-17 14:37:07 +02:00

129 lines
4 KiB
Text

[role="xpack"]
[[ml-revert-snapshot]]
= Revert model snapshots API
++++
<titleabbrev>Revert model snapshots</titleabbrev>
++++
Reverts to a specific snapshot.
[[ml-revert-snapshot-request]]
== {api-request-title}
`POST _ml/anomaly_detectors/<job_id>/model_snapshots/<snapshot_id>/_revert`
[[ml-revert-snapshot-prereqs]]
== {api-prereq-title}
* Before you revert to a saved snapshot, you must close the job.
* Requires the `manage_ml` cluster privilege. This privilege is included in the
`machine_learning_admin` built-in role.
[[ml-revert-snapshot-desc]]
== {api-description-title}
The {ml-features} react quickly to anomalous input, learning new
behaviors in data. Highly anomalous input increases the variance in the models
whilst the system learns whether this is a new step-change in behavior or a
one-off event. In the case where this anomalous input is known to be a one-off,
then it might be appropriate to reset the model state to a time before this
event. For example, you might consider reverting to a saved snapshot after Black
Friday or a critical system failure.
NOTE: Reverting to a snapshot does not change the `data_counts` values of the
{anomaly-job}, these values are not reverted to the earlier state.
[[ml-revert-snapshot-path-parms]]
== {api-path-parms-title}
`<job_id>`::
(Required, string)
include::{es-ref-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
`<snapshot_id>`::
(Required, string)
include::{es-ref-dir}/ml/ml-shared.asciidoc[tag=snapshot-id]
+
--
You can specify `empty` as the <snapshot_id>. Reverting to the `empty` snapshot
means the {anomaly-job} starts learning a new model from scratch when it is
started.
--
[[ml-revert-snapshot-query-parms]]
== {api-query-parms-title}
`delete_intervening_results`::
(Optional, Boolean) If true, deletes the results in the time period between
the latest results and the time of the reverted snapshot. It also resets the
model to accept records for this time period. The default value is false.
+
--
NOTE: If you choose not to delete intervening results when reverting a snapshot,
the job will not accept input data that is older than the current time.
If you want to resend data, then delete the intervening results.
--
[[ml-revert-snapshot-request-body]]
== {api-request-body-title}
You can also specify the `delete_intervening_results` query parameter in the
request body.
[[ml-revert-snapshot-example]]
== {api-examples-title}
[source,console]
--------------------------------------------------
POST _ml/anomaly_detectors/low_request_rate/model_snapshots/1637092688/_revert
{
"delete_intervening_results": true
}
--------------------------------------------------
// TEST[skip:todo]
When the operation is complete, you receive the following results:
[source,js]
----
{
"model" : {
"job_id" : "low_request_rate",
"min_version" : "7.11.0",
"timestamp" : 1637092688000,
"description" : "State persisted due to job close at 2021-11-16T19:58:08+0000",
"snapshot_id" : "1637092688",
"snapshot_doc_count" : 1,
"model_size_stats" : {
"job_id" : "low_request_rate",
"result_type" : "model_size_stats",
"model_bytes" : 45200,
"peak_model_bytes" : 101552,
"model_bytes_exceeded" : 0,
"model_bytes_memory_limit" : 11534336,
"total_by_field_count" : 3,
"total_over_field_count" : 0,
"total_partition_field_count" : 2,
"bucket_allocation_failures_count" : 0,
"memory_status" : "ok",
"assignment_memory_basis" : "current_model_bytes",
"categorized_doc_count" : 0,
"total_category_count" : 0,
"frequent_category_count" : 0,
"rare_category_count" : 0,
"dead_category_count" : 0,
"failed_category_count" : 0,
"categorization_status" : "ok",
"log_time" : 1637092688530,
"timestamp" : 1641495600000
},
"latest_record_time_stamp" : 1641502169000,
"latest_result_time_stamp" : 1641495600000,
"retain" : false
}
}
----
For a description of these properties, see the
<<ml-get-snapshot-results,get model snapshots API>>.