put-job.asciidoc 4.3 KB

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