put-job.asciidoc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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>> and {ml-docs-setup-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::{es-repo-dir}/ml/ml-shared.asciidoc[tag=job-id-anomaly-detection-define]
  28. [role="child_attributes"]
  29. [[ml-put-job-request-body]]
  30. == {api-request-body-title}
  31. `allow_lazy_open`::
  32. (Optional, boolean)
  33. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=allow-lazy-open]
  34. //Begin analysis_config
  35. [[put-analysisconfig]]`analysis_config`::
  36. (Required, object)
  37. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=analysis-config]
  38. +
  39. .Properties of `analysis_config`
  40. [%collapsible%open]
  41. ====
  42. `bucket_span`:::
  43. (<<time-units,time units>>)
  44. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=bucket-span]
  45. `categorization_analyzer`:::
  46. (object or string)
  47. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=categorization-analyzer]
  48. `categorization_field_name`:::
  49. (string)
  50. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=categorization-field-name]
  51. `categorization_filters`:::
  52. (array of strings)
  53. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=categorization-filters]
  54. //Begin analysis_config.detectors
  55. `detectors`:::
  56. (array) An array of detector configuration objects. Detector configuration
  57. objects specify which data fields a job analyzes. They also specify which
  58. analytical functions are used. You can specify multiple detectors for a job.
  59. +
  60. NOTE: If the `detectors` array does not contain at least one detector,
  61. no analysis can occur and an error is returned.
  62. +
  63. .Properties of `detectors`
  64. [%collapsible%open]
  65. =====
  66. `by_field_name`::::
  67. (string)
  68. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=by-field-name]
  69. //Begin analysis_config.detectors.custom_rules
  70. [[put-customrules]]`custom_rules`::::
  71. (array)
  72. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules]
  73. +
  74. .Properties of `custom_rules`
  75. [%collapsible%open]
  76. ======
  77. `actions`:::
  78. (array)
  79. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-actions]
  80. //Begin analysis_config.detectors.custom_rules.conditions
  81. `conditions`:::
  82. (array)
  83. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions]
  84. +
  85. .Properties of `conditions`
  86. [%collapsible%open]
  87. =======
  88. `applies_to`::::
  89. (string)
  90. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions-applies-to]
  91. `operator`::::
  92. (string)
  93. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions-operator]
  94. `value`::::
  95. (double)
  96. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-conditions-value]
  97. =======
  98. //End analysis_config.detectors.custom_rules.conditions
  99. //Begin analysis_config.detectors.custom_rules.scope
  100. `scope`:::
  101. (object)
  102. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-scope]
  103. +
  104. .Properties of `scope`
  105. [%collapsible%open]
  106. =======
  107. `filter_id`::::
  108. (string)
  109. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-scope-filter-id]
  110. `filter_type`::::
  111. (string)
  112. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-rules-scope-filter-type]
  113. =======
  114. //End analysis_config.detectors.custom_rules.scope
  115. ======
  116. //End analysis_config.detectors.custom_rules
  117. `detector_description`::::
  118. (string)
  119. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=detector-description]
  120. `detector_index`::::
  121. (integer)
  122. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=detector-index]
  123. +
  124. If you specify a value for this property, it is ignored.
  125. `exclude_frequent`::::
  126. (string)
  127. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=exclude-frequent]
  128. `field_name`::::
  129. (string)
  130. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=detector-field-name]
  131. `function`::::
  132. (string)
  133. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=function]
  134. `over_field_name`::::
  135. (string)
  136. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=over-field-name]
  137. `partition_field_name`::::
  138. (string)
  139. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=partition-field-name]
  140. `use_null`::::
  141. (boolean)
  142. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=use-null]
  143. =====
  144. //End analysis_config.detectors
  145. `influencers`:::
  146. (array of strings)
  147. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=influencers]
  148. `latency`:::
  149. (time units)
  150. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=latency]
  151. `multivariate_by_fields`:::
  152. (boolean)
  153. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=multivariate-by-fields]
  154. //Begin analysis_config.per_partition_categorization
  155. `per_partition_categorization`:::
  156. (Optional, object)
  157. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=per-partition-categorization]
  158. +
  159. .Properties of `per_partition_categorization`
  160. [%collapsible%open]
  161. =====
  162. `enabled`::::
  163. (boolean)
  164. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=per-partition-categorization-enabled]
  165. `stop_on_warn`::::
  166. (boolean)
  167. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=per-partition-categorization-stop-on-warn]
  168. =====
  169. //End analysis_config.per_partition_categorization
  170. `summary_count_field_name`:::
  171. (string)
  172. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=summary-count-field-name]
  173. ====
  174. //End analysis_config
  175. //Begin analysis_limits
  176. [[put-analysislimits]]`analysis_limits`::
  177. (Optional, object)
  178. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=analysis-limits]
  179. +
  180. .Properties of `analysis_limits`
  181. [%collapsible%open]
  182. ====
  183. `categorization_examples_limit`:::
  184. (long)
  185. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=categorization-examples-limit]
  186. `model_memory_limit`:::
  187. (long or string)
  188. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-memory-limit]
  189. ====
  190. //End analysis_limits
  191. `background_persist_interval`::
  192. (Optional, <<time-units, time units>>)
  193. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=background-persist-interval]
  194. [[put-customsettings]]`custom_settings`::
  195. (Optional, object)
  196. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=custom-settings]
  197. //Begin data_description
  198. [[put-datadescription]]`data_description`::
  199. (Required, object)
  200. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=data-description]
  201. //End data_description
  202. `daily_model_snapshot_retention_after_days`::
  203. (Optional, long)
  204. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=daily-model-snapshot-retention-after-days]
  205. `description`::
  206. (Optional, string) A description of the job.
  207. `groups`::
  208. (Optional, array of strings)
  209. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=groups]
  210. //Begin model_plot_config
  211. `model_plot_config`::
  212. (Optional, object)
  213. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-plot-config]
  214. +
  215. .Properties of `model_plot_config`
  216. [%collapsible%open]
  217. ====
  218. `annotations_enabled`:::
  219. (boolean)
  220. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-plot-config-annotations-enabled]
  221. `enabled`:::
  222. (boolean)
  223. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-plot-config-enabled]
  224. `terms`:::
  225. experimental[] (string)
  226. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-plot-config-terms]
  227. ====
  228. //End model_plot_config
  229. `model_snapshot_retention_days`::
  230. (Optional, long)
  231. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-snapshot-retention-days]
  232. `renormalization_window_days`::
  233. (Optional, long)
  234. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=renormalization-window-days]
  235. `results_index_name`::
  236. (Optional, string)
  237. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=results-index-name]
  238. `results_retention_days`::
  239. (Optional, long)
  240. include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=results-retention-days]
  241. [[ml-put-job-example]]
  242. == {api-examples-title}
  243. [source,console]
  244. --------------------------------------------------
  245. PUT _ml/anomaly_detectors/total-requests
  246. {
  247. "description" : "Total sum of requests",
  248. "analysis_config" : {
  249. "bucket_span":"10m",
  250. "detectors": [
  251. {
  252. "detector_description": "Sum of total",
  253. "function": "sum",
  254. "field_name": "total"
  255. }
  256. ]
  257. },
  258. "data_description" : {
  259. "time_field":"timestamp",
  260. "time_format": "epoch_ms"
  261. }
  262. }
  263. --------------------------------------------------
  264. When the job is created, you receive the following results:
  265. [source,console-result]
  266. ----
  267. {
  268. "job_id" : "total-requests",
  269. "job_type" : "anomaly_detector",
  270. "job_version" : "8.0.0",
  271. "description" : "Total sum of requests",
  272. "create_time" : 1562352500629,
  273. "analysis_config" : {
  274. "bucket_span" : "10m",
  275. "detectors" : [
  276. {
  277. "detector_description" : "Sum of total",
  278. "function" : "sum",
  279. "field_name" : "total",
  280. "detector_index" : 0
  281. }
  282. ],
  283. "influencers" : [ ]
  284. },
  285. "analysis_limits" : {
  286. "model_memory_limit" : "1024mb",
  287. "categorization_examples_limit" : 4
  288. },
  289. "data_description" : {
  290. "time_field" : "timestamp",
  291. "time_format" : "epoch_ms"
  292. },
  293. "model_snapshot_retention_days" : 10,
  294. "daily_model_snapshot_retention_after_days" : 1,
  295. "results_index_name" : "shared",
  296. "allow_lazy_open" : false
  297. }
  298. ----
  299. // TESTRESPONSE[s/"job_version" : "8.0.0"/"job_version" : $body.job_version/]
  300. // TESTRESPONSE[s/1562352500629/$body.$_path/]