put-job.asciidoc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. `analysis_config`.`bucket_span`:::
  37. (<<time-units,time units>>)
  38. include::{docdir}/ml/ml-shared.asciidoc[tag=bucket-span]
  39. `analysis_config`.`categorization_field_name`:::
  40. (string)
  41. include::{docdir}/ml/ml-shared.asciidoc[tag=categorization-field-name]
  42. `analysis_config`.`categorization_filters`:::
  43. (array of strings)
  44. include::{docdir}/ml/ml-shared.asciidoc[tag=categorization-filters]
  45. `analysis_config`.`categorization_analyzer`:::
  46. (object or string)
  47. include::{docdir}/ml/ml-shared.asciidoc[tag=categorization-analyzer]
  48. `analysis_config`.`detectors`:::
  49. (array) An array of detector configuration objects. Detector configuration
  50. objects specify which data fields a job analyzes. They also specify which
  51. analytical functions are used. You can specify multiple detectors for a job.
  52. +
  53. --
  54. NOTE: If the `detectors` array does not contain at least one detector,
  55. no analysis can occur and an error is returned.
  56. A detector has the following properties:
  57. --
  58. `analysis_config`.`detectors`.`by_field_name`::::
  59. (string)
  60. include::{docdir}/ml/ml-shared.asciidoc[tag=by-field-name]
  61. `analysis_config`.`detectors`.`custom_rules`::::
  62. +
  63. --
  64. (array)
  65. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules]
  66. `analysis_config`.`detectors`.`custom_rules`.`actions`:::
  67. (array)
  68. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-actions]
  69. `analysis_config`.`detectors`.`custom_rules`.`scope`:::
  70. (object)
  71. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-scope]
  72. `analysis_config`.`detectors`.`custom_rules`.`scope`.`filter_id`::::
  73. (string)
  74. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-scope-filter-id]
  75. `analysis_config`.`detectors`.`custom_rules`.`scope`.`filter_type`::::
  76. (string)
  77. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-scope-filter-type]
  78. `analysis_config`.`detectors`.`custom_rules`.`conditions`:::
  79. (array)
  80. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions]
  81. `analysis_config`.`detectors`.`custom_rules`.`conditions`.`applies_to`::::
  82. (string)
  83. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions-applies-to]
  84. `analysis_config`.`detectors`.`custom_rules`.`conditions`.`operator`::::
  85. (string)
  86. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions-operator]
  87. `analysis_config`.`detectors`.`custom_rules`.`conditions`.`value`::::
  88. (double)
  89. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions-value]
  90. --
  91. `analysis_config`.`detectors`.`detector_description`::::
  92. (string)
  93. include::{docdir}/ml/ml-shared.asciidoc[tag=detector-description]
  94. `analysis_config`.`detectors`.`detector_index`::::
  95. (integer)
  96. include::{docdir}/ml/ml-shared.asciidoc[tag=detector-index]
  97. `analysis_config`.`detectors`.`exclude_frequent`::::
  98. (string)
  99. include::{docdir}/ml/ml-shared.asciidoc[tag=exclude-frequent]
  100. `analysis_config`.`detectors`.`field_name`::::
  101. (string)
  102. include::{docdir}/ml/ml-shared.asciidoc[tag=detector-field-name]
  103. `analysis_config`.`detectors`.`function`::::
  104. (string)
  105. include::{docdir}/ml/ml-shared.asciidoc[tag=function]
  106. `analysis_config`.`detectors`.`over_field_name`::::
  107. (string)
  108. include::{docdir}/ml/ml-shared.asciidoc[tag=over-field-name]
  109. `analysis_config`.`detectors`.`partition_field_name`::::
  110. (string)
  111. include::{docdir}/ml/ml-shared.asciidoc[tag=partition-field-name]
  112. `analysis_config`.`detectors`.`use_null`::::
  113. (boolean)
  114. include::{docdir}/ml/ml-shared.asciidoc[tag=use-null]
  115. `analysis_config`.`influencers`:::
  116. (array of strings)
  117. include::{docdir}/ml/ml-shared.asciidoc[tag=influencers]
  118. `analysis_config`.`latency`:::
  119. (time units)
  120. include::{docdir}/ml/ml-shared.asciidoc[tag=latency]
  121. `analysis_config`.`multivariate_by_fields`:::
  122. (boolean)
  123. include::{docdir}/ml/ml-shared.asciidoc[tag=multivariate-by-fields]
  124. `analysis_config`.`summary_count_field_name`:::
  125. (string)
  126. include::{docdir}/ml/ml-shared.asciidoc[tag=summary-count-field-name]
  127. [[put-analysislimits]]`analysis_limits`::
  128. (Optional, object)
  129. include::{docdir}/ml/ml-shared.asciidoc[tag=analysis-limits]
  130. +
  131. --
  132. The `analysis_limits` object has the following properties:
  133. --
  134. `analysis_limits`.`categorization_examples_limit`:::
  135. (long)
  136. include::{docdir}/ml/ml-shared.asciidoc[tag=categorization-examples-limit]
  137. `analysis_limits`.`model_memory_limit`:::
  138. (long or string)
  139. include::{docdir}/ml/ml-shared.asciidoc[tag=model-memory-limit]
  140. `background_persist_interval`::
  141. (Optional, <<time-units, time units>>)
  142. include::{docdir}/ml/ml-shared.asciidoc[tag=background-persist-interval]
  143. [[put-customsettings]]`custom_settings`::
  144. (Optional, object)
  145. include::{docdir}/ml/ml-shared.asciidoc[tag=custom-settings]
  146. [[put-datadescription]]`data_description`::
  147. (Required, object)
  148. include::{docdir}/ml/ml-shared.asciidoc[tag=data-description]
  149. `description`::
  150. (Optional, string) A description of the job.
  151. `groups`::
  152. (Optional, array of strings)
  153. include::{docdir}/ml/ml-shared.asciidoc[tag=groups]
  154. `model_plot_config`::
  155. (Optional, object)
  156. include::{docdir}/ml/ml-shared.asciidoc[tag=model-plot-config]
  157. `model_plot_config`.`enabled`:::
  158. (boolean)
  159. include::{docdir}/ml/ml-shared.asciidoc[tag=model-plot-config-enabled]
  160. `model_plot_config`.`terms`:::
  161. experimental[] (string)
  162. include::{docdir}/ml/ml-shared.asciidoc[tag=model-plot-config-terms]
  163. `model_snapshot_retention_days`::
  164. (Optional, long)
  165. include::{docdir}/ml/ml-shared.asciidoc[tag=model-snapshot-retention-days]
  166. `renormalization_window_days`::
  167. (Optional, long)
  168. include::{docdir}/ml/ml-shared.asciidoc[tag=renormalization-window-days]
  169. `results_index_name`::
  170. (Optional, string)
  171. include::{docdir}/ml/ml-shared.asciidoc[tag=results-index-name]
  172. `results_retention_days`::
  173. (Optional, long)
  174. include::{docdir}/ml/ml-shared.asciidoc[tag=results-retention-days]
  175. [[ml-put-job-example]]
  176. ==== {api-examples-title}
  177. The following example creates the `total-requests` job:
  178. [source,console]
  179. --------------------------------------------------
  180. PUT _ml/anomaly_detectors/total-requests
  181. {
  182. "description" : "Total sum of requests",
  183. "analysis_config" : {
  184. "bucket_span":"10m",
  185. "detectors": [
  186. {
  187. "detector_description": "Sum of total",
  188. "function": "sum",
  189. "field_name": "total"
  190. }
  191. ]
  192. },
  193. "data_description" : {
  194. "time_field":"timestamp",
  195. "time_format": "epoch_ms"
  196. }
  197. }
  198. --------------------------------------------------
  199. When the job is created, you receive the following results:
  200. [source,console-result]
  201. ----
  202. {
  203. "job_id" : "total-requests",
  204. "job_type" : "anomaly_detector",
  205. "job_version" : "8.0.0",
  206. "description" : "Total sum of requests",
  207. "create_time" : 1562352500629,
  208. "analysis_config" : {
  209. "bucket_span" : "10m",
  210. "detectors" : [
  211. {
  212. "detector_description" : "Sum of total",
  213. "function" : "sum",
  214. "field_name" : "total",
  215. "detector_index" : 0
  216. }
  217. ],
  218. "influencers" : [ ]
  219. },
  220. "analysis_limits" : {
  221. "model_memory_limit" : "1024mb",
  222. "categorization_examples_limit" : 4
  223. },
  224. "data_description" : {
  225. "time_field" : "timestamp",
  226. "time_format" : "epoch_ms"
  227. },
  228. "model_snapshot_retention_days" : 1,
  229. "results_index_name" : "shared",
  230. "allow_lazy_open" : false
  231. }
  232. ----
  233. // TESTRESPONSE[s/"job_version" : "8.0.0"/"job_version" : $body.job_version/]
  234. // TESTRESPONSE[s/1562352500629/$body.$_path/]