put-job.asciidoc 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. {stack-ov}/security-privileges.html[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) Identifier for the job. This identifier can contain
  27. lowercase alphanumeric characters (a-z and 0-9), hyphens, and underscores. It
  28. must start and end with alphanumeric characters.
  29. [[ml-put-job-request-body]]
  30. ==== {api-request-body-title}
  31. `analysis_config`::
  32. (Required, object) The analysis configuration, which specifies how to analyze
  33. the data. See <<ml-analysisconfig, analysis configuration objects>>.
  34. `analysis_limits`::
  35. (Optional, object) Specifies runtime limits for the job. See
  36. <<ml-apilimits,analysis limits>>.
  37. `background_persist_interval`::
  38. (Optional, time units) Advanced configuration option. The time between each
  39. periodic persistence of the model. See <<ml-job-resource>>.
  40. `custom_settings`::
  41. (Optional, object) Advanced configuration option. Contains custom meta data
  42. about the job. See <<ml-job-resource>>.
  43. `data_description`::
  44. (Required, object) Describes the format of the input data. This object is
  45. required, but it can be empty (`{}`). See
  46. <<ml-datadescription,data description objects>>.
  47. `description`::
  48. (Optional, string) A description of the job.
  49. `groups`::
  50. (Optional, array of strings) A list of job groups. See <<ml-job-resource>>.
  51. `model_plot_config`::
  52. (Optional, object) Advanced configuration option. Specifies to store model
  53. information along with the results. This adds overhead to the performance of
  54. the system and is not feasible for jobs with many entities, see
  55. <<ml-apimodelplotconfig>>.
  56. `model_snapshot_retention_days`::
  57. (Optional, long) The time in days that model snapshots are retained for the
  58. job. Older snapshots are deleted. The default value is `1`, which means
  59. snapshots are retained for one day (twenty-four hours).
  60. `renormalization_window_days`::
  61. (Optional, long) Advanced configuration option. The period over which
  62. adjustments to the score are applied, as new data is seen. See
  63. <<ml-job-resource>>.
  64. `results_index_name`::
  65. (Optional, string) A text string that affects the name of the {ml} results
  66. index. The default value is `shared`, which generates an index named
  67. `.ml-anomalies-shared`.
  68. `results_retention_days`::
  69. (Optional, long) Advanced configuration option. The number of days for which
  70. job results are retained. See <<ml-job-resource>>.
  71. [[ml-put-job-example]]
  72. ==== {api-examples-title}
  73. The following example creates the `total-requests` job:
  74. [source,js]
  75. --------------------------------------------------
  76. PUT _ml/anomaly_detectors/total-requests
  77. {
  78. "description" : "Total sum of requests",
  79. "analysis_config" : {
  80. "bucket_span":"10m",
  81. "detectors": [
  82. {
  83. "detector_description": "Sum of total",
  84. "function": "sum",
  85. "field_name": "total"
  86. }
  87. ]
  88. },
  89. "data_description" : {
  90. "time_field":"timestamp",
  91. "time_format": "epoch_ms"
  92. }
  93. }
  94. --------------------------------------------------
  95. // CONSOLE
  96. When the job is created, you receive the following results:
  97. [source,js]
  98. ----
  99. {
  100. "job_id" : "total-requests",
  101. "job_type" : "anomaly_detector",
  102. "job_version" : "8.0.0",
  103. "description" : "Total sum of requests",
  104. "create_time" : 1562352500629,
  105. "analysis_config" : {
  106. "bucket_span" : "10m",
  107. "detectors" : [
  108. {
  109. "detector_description" : "Sum of total",
  110. "function" : "sum",
  111. "field_name" : "total",
  112. "detector_index" : 0
  113. }
  114. ],
  115. "influencers" : [ ]
  116. },
  117. "analysis_limits" : {
  118. "model_memory_limit" : "1024mb",
  119. "categorization_examples_limit" : 4
  120. },
  121. "data_description" : {
  122. "time_field" : "timestamp",
  123. "time_format" : "epoch_ms"
  124. },
  125. "model_snapshot_retention_days" : 1,
  126. "results_index_name" : "shared"
  127. }
  128. ----
  129. // TESTRESPONSE[s/"job_version" : "8.0.0"/"job_version" : $body.job_version/]
  130. // TESTRESPONSE[s/1562352500629/$body.$_path/]