revert-snapshot.asciidoc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. [role="xpack"]
  2. [[ml-revert-snapshot]]
  3. = Revert model snapshots API
  4. ++++
  5. <titleabbrev>Revert model snapshots</titleabbrev>
  6. ++++
  7. Reverts to a specific snapshot.
  8. [[ml-revert-snapshot-request]]
  9. == {api-request-title}
  10. `POST _ml/anomaly_detectors/<job_id>/model_snapshots/<snapshot_id>/_revert`
  11. [[ml-revert-snapshot-prereqs]]
  12. == {api-prereq-title}
  13. * Before you revert to a saved snapshot, you must close the job.
  14. * Requires the `manage_ml` cluster privilege. This privilege is included in the
  15. `machine_learning_admin` built-in role.
  16. [[ml-revert-snapshot-desc]]
  17. == {api-description-title}
  18. The {ml-features} react quickly to anomalous input, learning new
  19. behaviors in data. Highly anomalous input increases the variance in the models
  20. whilst the system learns whether this is a new step-change in behavior or a
  21. one-off event. In the case where this anomalous input is known to be a one-off,
  22. then it might be appropriate to reset the model state to a time before this
  23. event. For example, you might consider reverting to a saved snapshot after Black
  24. Friday or a critical system failure.
  25. NOTE: Reverting to a snapshot does not change the `data_counts` values of the
  26. {anomaly-job}, these values are not reverted to the earlier state.
  27. [[ml-revert-snapshot-path-parms]]
  28. == {api-path-parms-title}
  29. `<job_id>`::
  30. (Required, string)
  31. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection]
  32. `<snapshot_id>`::
  33. (Required, string)
  34. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=snapshot-id]
  35. +
  36. --
  37. You can specify `empty` as the <snapshot_id>. Reverting to the `empty` snapshot
  38. means the {anomaly-job} starts learning a new model from scratch when it is
  39. started.
  40. --
  41. [[ml-revert-snapshot-query-parms]]
  42. == {api-query-parms-title}
  43. `delete_intervening_results`::
  44. (Optional, Boolean) If true, deletes the results in the time period between
  45. the latest results and the time of the reverted snapshot. It also resets the
  46. model to accept records for this time period. The default value is false.
  47. +
  48. --
  49. NOTE: If you choose not to delete intervening results when reverting a snapshot,
  50. the job will not accept input data that is older than the current time.
  51. If you want to resend data, then delete the intervening results.
  52. --
  53. [[ml-revert-snapshot-request-body]]
  54. == {api-request-body-title}
  55. You can also specify the `delete_intervening_results` query parameter in the
  56. request body.
  57. [[ml-revert-snapshot-example]]
  58. == {api-examples-title}
  59. [source,console]
  60. --------------------------------------------------
  61. POST _ml/anomaly_detectors/low_request_rate/model_snapshots/1637092688/_revert
  62. {
  63. "delete_intervening_results": true
  64. }
  65. --------------------------------------------------
  66. // TEST[skip:todo]
  67. When the operation is complete, you receive the following results:
  68. [source,js]
  69. ----
  70. {
  71. "model" : {
  72. "job_id" : "low_request_rate",
  73. "min_version" : "7.11.0",
  74. "timestamp" : 1637092688000,
  75. "description" : "State persisted due to job close at 2021-11-16T19:58:08+0000",
  76. "snapshot_id" : "1637092688",
  77. "snapshot_doc_count" : 1,
  78. "model_size_stats" : {
  79. "job_id" : "low_request_rate",
  80. "result_type" : "model_size_stats",
  81. "model_bytes" : 45200,
  82. "peak_model_bytes" : 101552,
  83. "model_bytes_exceeded" : 0,
  84. "model_bytes_memory_limit" : 11534336,
  85. "total_by_field_count" : 3,
  86. "total_over_field_count" : 0,
  87. "total_partition_field_count" : 2,
  88. "bucket_allocation_failures_count" : 0,
  89. "memory_status" : "ok",
  90. "assignment_memory_basis" : "current_model_bytes",
  91. "categorized_doc_count" : 0,
  92. "total_category_count" : 0,
  93. "frequent_category_count" : 0,
  94. "rare_category_count" : 0,
  95. "dead_category_count" : 0,
  96. "failed_category_count" : 0,
  97. "categorization_status" : "ok",
  98. "log_time" : 1637092688530,
  99. "timestamp" : 1641495600000
  100. },
  101. "latest_record_time_stamp" : 1641502169000,
  102. "latest_result_time_stamp" : 1641495600000,
  103. "retain" : false
  104. }
  105. }
  106. ----
  107. For a description of these properties, see the
  108. <<ml-get-snapshot-results,get model snapshots API>>.