put-job.asciidoc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. --
  2. :api: put-job
  3. :request: PutJobRequest
  4. :response: PutJobResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Put Job API
  8. The Put Job API can be used to create a new {ml} job
  9. in the cluster. The API accepts a +{request}+ object
  10. as a request and returns a +{response}+.
  11. [id="{upid}-{api}-request"]
  12. ==== Put Job Request
  13. A +{request}+ requires the following argument:
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests-file}[{api}-request]
  17. --------------------------------------------------
  18. <1> The configuration of the {ml} job to create as a `Job`
  19. [id="{upid}-{api}-config"]
  20. ==== Job Configuration
  21. The `Job` object contains all the details about the {ml} job
  22. configuration.
  23. A `Job` requires the following arguments:
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests-file}[{api}-config]
  27. --------------------------------------------------
  28. <1> The job ID
  29. <2> An analysis configuration
  30. <3> A data description
  31. <4> Optionally, a human-readable description
  32. [id="{upid}-{api}-analysis-config"]
  33. ==== Analysis Configuration
  34. The analysis configuration of the {ml} job is defined in the `AnalysisConfig`.
  35. `AnalysisConfig` reflects all the configuration
  36. settings that can be defined using the REST API.
  37. Using the REST API, we could define this analysis configuration:
  38. [source,js]
  39. --------------------------------------------------
  40. "analysis_config" : {
  41. "bucket_span" : "10m",
  42. "detectors" : [
  43. {
  44. "detector_description" : "Sum of total",
  45. "function" : "sum",
  46. "field_name" : "total"
  47. }
  48. ]
  49. }
  50. --------------------------------------------------
  51. // NOTCONSOLE
  52. Using the `AnalysisConfig` object and the high level REST client, the list
  53. of detectors must be built first.
  54. An example of building a `Detector` instance is as follows:
  55. ["source","java",subs="attributes,callouts,macros"]
  56. --------------------------------------------------
  57. include-tagged::{doc-tests-file}[{api}-detector]
  58. --------------------------------------------------
  59. <1> The function to use
  60. <2> The field to apply the function to
  61. <3> Optionally, a human-readable description
  62. Then the same configuration would be:
  63. ["source","java",subs="attributes,callouts,macros"]
  64. --------------------------------------------------
  65. include-tagged::{doc-tests-file}[{api}-analysis-config]
  66. --------------------------------------------------
  67. <1> Create a list of detectors
  68. <2> Pass the list of detectors to the analysis config builder constructor
  69. <3> The bucket span
  70. [id="{upid}-{api}-data-description"]
  71. ==== Data Description
  72. After defining the analysis config, the next thing to define is the
  73. data description, using a `DataDescription` instance. `DataDescription`
  74. reflects all the configuration settings that can be defined using the
  75. REST API.
  76. Using the REST API, we could define this metrics configuration:
  77. [source,js]
  78. --------------------------------------------------
  79. "data_description" : {
  80. "time_field" : "timestamp"
  81. }
  82. --------------------------------------------------
  83. // NOTCONSOLE
  84. Using the `DataDescription` object and the high level REST client, the same
  85. configuration would be:
  86. ["source","java",subs="attributes,callouts,macros"]
  87. --------------------------------------------------
  88. include-tagged::{doc-tests-file}[{api}-data-description]
  89. --------------------------------------------------
  90. <1> The time field
  91. include::../execution.asciidoc[]
  92. [id="{upid}-{api}-response"]
  93. ==== Response
  94. The returned +{response}+ returns the full representation of
  95. the new {ml} job if it has been successfully created. This will
  96. contain the creation time and other fields initialized using
  97. default values:
  98. ["source","java",subs="attributes,callouts,macros"]
  99. --------------------------------------------------
  100. include-tagged::{doc-tests-file}[{api}-response]
  101. --------------------------------------------------
  102. <1> The creation time is a field that was not passed in the `Job` object in the request