put-job.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-put-job]]
  4. === Create {anomaly-jobs} API
  5. ++++
  6. <titleabbrev>Create jobs</titleabbrev>
  7. ++++
  8. Instantiates an {anomaly-job}.
  9. [[ml-put-job-request]]
  10. ==== {api-request-title}
  11. `PUT _ml/anomaly_detectors/<job_id>`
  12. [[ml-put-job-prereqs]]
  13. ==== {api-prereq-title}
  14. * If the {es} {security-features} are enabled, you must have `manage_ml` or
  15. `manage` cluster privileges to use this API. See
  16. <<security-privileges>>.
  17. [[ml-put-job-desc]]
  18. ==== {api-description-title}
  19. IMPORTANT: You must use {kib} or this API to create an {anomaly-job}. Do not put
  20. a job directly to the `.ml-config` index using the {es} index API. If {es}
  21. {security-features} are enabled, do not give users `write` privileges on the
  22. `.ml-config` index.
  23. [[ml-put-job-path-parms]]
  24. ==== {api-path-parms-title}
  25. `<job_id>`::
  26. (Required, string)
  27. include::{docdir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-define]
  28. [[ml-put-job-request-body]]
  29. ==== {api-request-body-title}
  30. `allow_lazy_open`::
  31. (Optional, boolean)
  32. include::{docdir}/ml/ml-shared.asciidoc[tag=allow-lazy-open]
  33. [[put-analysisconfig]]`analysis_config`::
  34. (Required, object)
  35. include::{docdir}/ml/ml-shared.asciidoc[tag=analysis-config]
  36. [[put-analysislimits]]`analysis_limits`::
  37. (Optional, object)
  38. include::{docdir}/ml/ml-shared.asciidoc[tag=analysis-limits]
  39. `background_persist_interval`::
  40. (Optional, <<time-units, time units>>)
  41. include::{docdir}/ml/ml-shared.asciidoc[tag=background-persist-interval]
  42. [[put-customsettings]]`custom_settings`::
  43. (Optional, object)
  44. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-settings]
  45. [[put-datadescription]]`data_description`::
  46. (Required, object)
  47. include::{docdir}/ml/ml-shared.asciidoc[tag=data-description]
  48. `description`::
  49. (Optional, string) A description of the job.
  50. `groups`::
  51. (Optional, array of strings)
  52. include::{docdir}/ml/ml-shared.asciidoc[tag=groups]
  53. `model_plot_config`::
  54. (Optional, object)
  55. include::{docdir}/ml/ml-shared.asciidoc[tag=model-plot-config]
  56. `model_snapshot_retention_days`::
  57. (Optional, long)
  58. include::{docdir}/ml/ml-shared.asciidoc[tag=model-snapshot-retention-days]
  59. `renormalization_window_days`::
  60. (Optional, long)
  61. include::{docdir}/ml/ml-shared.asciidoc[tag=renormalization-window-days]
  62. `results_index_name`::
  63. (Optional, string)
  64. include::{docdir}/ml/ml-shared.asciidoc[tag=results-index-name]
  65. `results_retention_days`::
  66. (Optional, long)
  67. include::{docdir}/ml/ml-shared.asciidoc[tag=results-retention-days]
  68. [[ml-put-job-example]]
  69. ==== {api-examples-title}
  70. The following example creates the `total-requests` job:
  71. [source,console]
  72. --------------------------------------------------
  73. PUT _ml/anomaly_detectors/total-requests
  74. {
  75. "description" : "Total sum of requests",
  76. "analysis_config" : {
  77. "bucket_span":"10m",
  78. "detectors": [
  79. {
  80. "detector_description": "Sum of total",
  81. "function": "sum",
  82. "field_name": "total"
  83. }
  84. ]
  85. },
  86. "data_description" : {
  87. "time_field":"timestamp",
  88. "time_format": "epoch_ms"
  89. }
  90. }
  91. --------------------------------------------------
  92. When the job is created, you receive the following results:
  93. [source,console-result]
  94. ----
  95. {
  96. "job_id" : "total-requests",
  97. "job_type" : "anomaly_detector",
  98. "job_version" : "8.0.0",
  99. "description" : "Total sum of requests",
  100. "create_time" : 1562352500629,
  101. "analysis_config" : {
  102. "bucket_span" : "10m",
  103. "detectors" : [
  104. {
  105. "detector_description" : "Sum of total",
  106. "function" : "sum",
  107. "field_name" : "total",
  108. "detector_index" : 0
  109. }
  110. ],
  111. "influencers" : [ ]
  112. },
  113. "analysis_limits" : {
  114. "model_memory_limit" : "1024mb",
  115. "categorization_examples_limit" : 4
  116. },
  117. "data_description" : {
  118. "time_field" : "timestamp",
  119. "time_format" : "epoch_ms"
  120. },
  121. "model_snapshot_retention_days" : 1,
  122. "results_index_name" : "shared",
  123. "allow_lazy_open" : false
  124. }
  125. ----
  126. // TESTRESPONSE[s/"job_version" : "8.0.0"/"job_version" : $body.job_version/]
  127. // TESTRESPONSE[s/1562352500629/$body.$_path/]