put-job.asciidoc 4.6 KB

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