put-job.asciidoc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. [role="xpack"]
  2. [testenv="platinum"]
  3. [[ml-put-job]]
  4. === Create {anomaly-jobs} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {anomaly-jobs}</titleabbrev>
  8. ++++
  9. Instantiates an {anomaly-job}.
  10. [[ml-put-job-request]]
  11. ==== {api-request-title}
  12. `PUT _ml/anomaly_detectors/<job_id>`
  13. [[ml-put-job-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have `manage_ml` or
  16. `manage` cluster privileges to use this API. See
  17. {stack-ov}/security-privileges.html[Security privileges].
  18. [[ml-put-job-desc]]
  19. ==== {api-description-title}
  20. IMPORTANT: You must use {kib} or this API to create an {anomaly-job}. Do not put
  21. a job directly to the `.ml-config` index using the {es} index API. If {es}
  22. {security-features} are enabled, do not give users `write` privileges on the
  23. `.ml-config` index.
  24. [[ml-put-job-path-parms]]
  25. ==== {api-path-parms-title}
  26. `<job_id>` (Required)::
  27. (string) Identifier for the job. This identifier can contain lowercase
  28. alphanumeric characters (a-z and 0-9), hyphens, and underscores. It must
  29. start and end with alphanumeric characters.
  30. [[ml-put-job-request-body]]
  31. ==== {api-request-body-title}
  32. `analysis_config` (Required)::
  33. (object) The analysis configuration, which specifies how to analyze the data.
  34. See <<ml-analysisconfig, analysis configuration objects>>.
  35. `analysis_limits` (Optional)::
  36. (object) Specifies runtime limits for the job. See
  37. <<ml-apilimits,analysis limits>>.
  38. `background_persist_interval` (Optional)::
  39. (time units) Advanced configuration option. The time between each periodic
  40. persistence of the model. See <<ml-job-resource>>.
  41. `custom_settings` (Optional)::
  42. (object) Advanced configuration option. Contains custom meta data about the
  43. job. See <<ml-job-resource>>.
  44. `data_description` (Required)::
  45. (object) Describes the format of the input data. This object is required, but
  46. it can be empty (`{}`). See <<ml-datadescription,data description objects>>.
  47. `description` (Optional)::
  48. (string) A description of the job.
  49. `groups` (Optional)::
  50. (array of strings) A list of job groups. See <<ml-job-resource>>.
  51. `model_plot_config` (Optional)::
  52. (object) Advanced configuration option. Specifies to store model information
  53. along with the results. This adds overhead to the performance of the system
  54. and is not feasible for jobs with many entities, see <<ml-apimodelplotconfig>>.
  55. `model_snapshot_retention_days` (Optional)::
  56. (long) The time in days that model snapshots are retained for the job.
  57. Older snapshots are deleted. The default value is `1`, which means snapshots
  58. are retained for one day (twenty-four hours).
  59. `renormalization_window_days` (Optional)::
  60. (long) Advanced configuration option. The period over which adjustments to the
  61. score are applied, as new data is seen. See <<ml-job-resource>>.
  62. `results_index_name` (Optional)::
  63. (string) A text string that affects the name of the {ml} results index. The
  64. default value is `shared`, which generates an index named `.ml-anomalies-shared`.
  65. `results_retention_days` (Optional)::
  66. (long) Advanced configuration option. The number of days for which job results
  67. are retained. See <<ml-job-resource>>.
  68. [[ml-put-job-example]]
  69. ==== {api-examples-title}
  70. The following example creates the `total-requests` job:
  71. [source,js]
  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. // CONSOLE
  93. // TEST[skip: https://github.com/elastic/elasticsearch/issues/43271]
  94. When the job is created, you receive the following results:
  95. [source,js]
  96. ----
  97. {
  98. "job_id" : "total-requests",
  99. "job_type" : "anomaly_detector",
  100. "job_version" : "8.0.0",
  101. "description" : "Total sum of requests",
  102. "create_time" : 1562352500629,
  103. "analysis_config" : {
  104. "bucket_span" : "10m",
  105. "detectors" : [
  106. {
  107. "detector_description" : "Sum of total",
  108. "function" : "sum",
  109. "field_name" : "total",
  110. "detector_index" : 0
  111. }
  112. ],
  113. "influencers" : [ ]
  114. },
  115. "analysis_limits" : {
  116. "model_memory_limit" : "1024mb",
  117. "categorization_examples_limit" : 4
  118. },
  119. "data_description" : {
  120. "time_field" : "timestamp",
  121. "time_format" : "epoch_ms"
  122. },
  123. "model_snapshot_retention_days" : 1,
  124. "results_index_name" : "shared"
  125. }
  126. ----
  127. // TESTRESPONSE[s/"job_version" : "8.0.0"/"job_version" : $body.job_version/]
  128. // TESTRESPONSE[s/1562352500629/$body.$_path/]